9/30/2012

BCS1233 AD : Pseudocode Exercise

There are two most commonly algorithm used to describe process ; flowchart and pseudocode ( pronounce as -′süd·ō′kōd ).  Consider the following problems and learn how the pseudocode is constructed.

1. Write a pseudocode to find the perimeter and area of a rectangle
The perimeter and area of the rectangle are given by the following formulas:
  perimeter = 2 * (length + width)
  area = length * width

1.PROMPT user to enter length and width
2.READ length and width
3. CALCULATE perimeter and area
       perimeter = 2 * (length + width)
       area = length * width
4. OUTPUT perimeter and area


2. Write a pseudocode which inputs a length in inches, and outputs its equivalent in centimeters (1 inch = 2.54 centimeters)

1.PROMPT user to enter inch
2.READ inch
3. CONVERT inch into centimeters
      centimeters = inch * 2.54
4. OUTPUT centimeters

 Now, its your turn -write a pseudocode for the following problems.

1.(Converting feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meters.


2.*(Calculating tips) Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

3.*(Payroll) Write a program that reads the following information and prints a payroll statement:
Employee's name (e.g., Smith)

Number of hours worked in a week (e.g., 10)

Hourly pay rate (e.g., 6.75)

Federal tax withholding rate (e.g., 20%)

State tax withholding rate (e.g., 9%)



A sample run of a program is shown in below:-



The level of difficulty is rated as easy (no star), moderate (*), hard (**), or challenging (***).

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...