Académique Documents
Professionnel Documents
Culture Documents
Analyze each problem and identify the input, formula and the output. Write the pseudo code and draw the flowchart for each.
1.0 Read three numbers. Calculate the sum of those three numbers and find the average. Display all the three numbers, as well as the total of those numbers and the in average. Output: sum and average Input: no 1, no 2, no 3 Process: Average = no 1 + no 2 + no 3 3
Pseudo code design: 1) 2) 3) 4) 5) 6) Start Read no.1, no.2, no.3 Sum of this three no. = no.1 + no.2 + no.3 Calculate the average = total / 3 Display the average End
Flow chart ;
Start
Average = total /3
Display average
End
Code c++
2.0 Convert the temperature entered by the user in the unit of Fahrenheit to the unit of Celcius. The conversion formula as follows: Fahrenheit = [Celsius * (9/2)] +32 Output: Display the conversion Input: temperature Process: Fahrenheit = [Celsius * (9/2)] +32
Pseudo code design: 1) Start 2) Read the temperature 3) Convert from Celsius to Fahrenheit use this formula: Celcius = (fahreinheit-32)*5/9 4) Display the conversion 5) End
Celcius = (fahreinheit-32)*5/9
End
3.0 Convert the flow chart into correct C++ code. Start
Read quantity
Read payment
End
4.0 Read the radius of a circle, and compute the area of that circle. Test your logic by applying the input values of radius as follows: i. ii. iii. 67 320 19
Put radius
Display area
End
9.0 Calculate the payment for normal and overtime working hours of an employee. Flow charts: Start
Working hours=8
Overtime hours= 10
End
Pseudo code for normal payment 1. 2. 3. 4. 5. 6. 7. 8. 9. Start Set normal pay rate Set normal hours Calculate normal payment= normal pay rate x normal hours and store in Set overtime pay rate Set overtime hours Overtime payment = overtime pay rate * overtime hours Display normal payment and overtime payment End
5.0 Calculate the total cost of item purchased. The input for the variables are as follows: i. Item name: pensile Price per unit: 0.50 Quantity: 15 Amount paid: 10.00 Item name: note book Price per unit: 2.00 Quantity: 5 Amount paid: 10.00 Item name: pen Price per unit: 1.20 Quantity: 3 Amount paid: 5.00
Start
iii.
Read quantity
Read payment
End
6.0 Read in the tax rate (as a percentage) and the prices of five items. The program is to calculate the total price of the items before tax then the tax payable on those items. The tax payable is calculated by applying the tax rate percentage to the total price. Print the total price and the tax payable as output.
Start
Read price
End
Pseudo code 1. 2. 3. 4. 5. 6. 7. Start Get A,B,C,D,E Calculate x = A+B+C+D+E and store in total price Get y in % and store in tax total Calculate z = (y/100) * x and store in tax payable Display A,B,C,D,E,x,y,z End
7.0 Read in three values from a customers bank account; the account balance at the beginning of the month, a total of all withdrawals from the account for the month, and a total of all the deposits into the account during the month. A federal tax charge of 1% is applied to all transactions made by the month. The program is to calculate the account balance at the end of the month by (1) subtracting the total withdrawals from the accounts balance at the beginning of the month, (2) adding the total deposits to this new balance, (3) calculating the federal tax (1% of total transactions that is, total withdrawals + total deposits), and (4) subtracting this federal tax from the new balance. After these calculations print the final end of month balance.