Pseudocode Development

Pseudocode Development. Problem: Write an algorithm that will receive prices of two items, calculate their total and the sales tax on the purchase (assume 8%) ...
31KB taille 2 téléchargements 240 vues
Pseudocode Development Problem: Write an algorithm that will receive prices of two items, calculate their total and the sales tax on the purchase (assume 8%) and then output total cost of the purchase to the screen. A. Defining Diagram Input Cost_Item_1 Cost_Item_2

Processing Obtain item prices Calculate total price including the tax Display result

Output Total_Price

B. Solution Algorithm CALCULATE_TOTAL_PRICE Prompt user for the cost of the first item 1. Get Cost_Item_1 Prompt user for the cost of the second item 2. Get Cost_Item_2 3. Calculate the Sum of Coast_Item_1 and Cost_Item_2 4. Calculate Tax = Sum * 0.08 5. Calculate Total_Price = Sum + Tax 6. Display Total_Price END C. Desk Checking/Trace First Pass Inputs: 10, 20

Expected Output: 32.4

Second Pass Inputs: 0.5, 100

Expected Output: 108.54

A table with all major steps in the algorithm and all variables:

1 2 3 4 5 6 1 2 3 4 5 6

Cost_Item_1 Cost_Item_2 10 20

Sum

Tax

Total_Price

30 2.4 32.4 yes 0.5 100 100.5 8.04 108.54 yes