Upload
mohd-zamzuri
View
216
Download
0
Embed Size (px)
Citation preview
7/30/2019 Asigment c++ New
1/13
Given the following set of problems. Analyze each problem and identify the input, formula and the
output. Write the pseudo code and draw the flowchart for each.
1.0Read three numbers. Calculate the sum of those three numbers and find the average. Display allthe 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) Start2) Read no.1, no.2, no.33) Sum of this three no. = no.1 + no.2 + no.34) Calculate the average = total / 35) Display the average6)
End
7/30/2019 Asigment c++ New
2/13
Flow chart ;
Code c++
Start
Read no.1, no. 2, no.3
Total = no.1 + no.2 +no. 3
Average = total /3
Display average
End
7/30/2019 Asigment c++ New
3/13
2.0Convert the temperature entered by the user in the unit of Fahrenheit to the unit of Celcius. Theconversion formula as follows:
Fahrenheit = [Celsius * (9/2)] +32
Output: Display the conversion
Input: temperature
Process: Fahrenheit = [Celsius * (9/2)] +32
Pseudo code design:
1) Start2) Read the temperature3) Convert from Celsius to Fahrenheit use this formula:
Celcius = (fahreinheit-32)*5/9
4) Display the conversion5) End
Flow chart:
Start
Read the temperature
Celcius = (fahreinheit-32)*5/9
Display the conversion
End
7/30/2019 Asigment c++ New
4/13
7/30/2019 Asigment c++ New
5/13
3.0Convert the flow chart into correct C++ code.Start
Read item name
Read uantit
Read price per unit
Display item name, payment,
total cost, and pay change
Read payment
Display total payment
Total cost = quantity * price per unit
Pay change = payment total cost
End
7/30/2019 Asigment c++ New
6/13
4.0Read the radius of a circle, and compute the area of that circle. Test your logic by applying theinput values of radius as follows:
i. 67ii. 320
iii. 19Flow charts:
Start
Put radius
Set pie = 3.142
Area = pie * r*r
Display area
End
7/30/2019 Asigment c++ New
7/13
7/30/2019 Asigment c++ New
8/13
9.0 Calculate the payment for normal and overtime working hours of an employee.
Flow charts:
Start
Set normal pay rate = 30.00
Normal pay = 8 * 30.00
Set overtime pay rate = 10.00
Overtime pay = 10 * 10.00
End
Working hours=8
Overtime hours= 10
Display total pay
Total pay = normal pay*overtime pay
7/30/2019 Asigment c++ New
9/13
Pseudo code for normal payment
1. Start2. Set normal pay rate3. Set normal hours4. Calculate normal payment= normal pay rate x normal hours and store in5. Set overtime pay rate6. Set overtime hours7. Overtime payment = overtime pay rate * overtime hours8. Display normal payment and overtime payment9. End
7/30/2019 Asigment c++ New
10/13
5.0Calculate the total cost of item purchased. The input for the variables are as follows:i. Item name: pensile
Price per unit: 0.50Quantity: 15
Amount paid: 10.00
ii. Item name: note bookPrice per unit: 2.00
Quantity: 5
Amount paid: 10.00
iii. Item name: penPrice per unit: 1.20Quantity: 3
Amount paid: 5.00
Start
Read item name
Read uantit
Display item name, payment,
total cost, and pay change
Read payment
Display total payment
Total cost = quantity * price per unit
Pay change = payment total cost
End
Read price per unit
7/30/2019 Asigment c++ New
11/13
6.0Read in the tax rate (as a percentage) and the prices of five items. The program is to calculatethe 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 tax rate
Read rice
Tax pay = tax rate percentage * total price
Display total price
and tax price
End
7/30/2019 Asigment c++ New
12/13
Pseudo code
1. Start2. Get A,B,C,D,E3. Calculate x = A+B+C+D+E and store in total price4. Get y in % and store in tax total5. Calculate z = (y/100) * x and store in tax payable6. Display A,B,C,D,E,x,y,z7. End
7/30/2019 Asigment c++ New
13/13
7.0Read in three values from a customers bank account; the account balance at the beginning ofthe 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.