In: Computer Science
A customer in a store is purchasing two items. Design a program using module pseudocode that asks for the price of each item in dollars, and then displays three things in their output receipt - the subtotal of the sale in dollars, the amount of sales tax in dollars and the final amount paid by the customer in dollars. Assume the sales tax is 4 percent.
// Pseudocode to display the receipt of purchasing two items
Module main
// declare variables to store price of 2 items,
subtotal, sales tax and total paid by user
declare Real item1_price
declare Real item2_price
declare Real subtotal
declare Real total
declare Real salesTax
// input the price for item1 and item2
Display "Enter price of item1 in dollars: "
getPrice(item1_price)
Display "Enter price of item2 in dollars: "
getPrice(item2_price)
// calculate the subtotal, sales tax and total
amount
calculateTotal(item1_price, item2_price, subtotal,
salesTax, total)
// display the receipt containing subtotal, sales tax
and total
displayReceipt(subtotal, salesTax, total)
End Module
// Module to input and return the price of the item
Module getPrice(Real ref price)
Input price
End Module
// Module to calculate the total of 2 item price, sales tax on the
subtotal and total amount to be paid by the user
Module calculateTotal(Real item1_price, Real item2_price, Real ref
subtotal, Real ref salesTax, Real ref total)
// declare variable to store the sales tax
percent
declare Real salesTaxPercent;
Set salesTaxPercent to 4;
// calculate subtotal as total of prices of both
items
subtotal = item1_price + item2_price;
// calculate sales tax
salesTax = (subtotal*salesTaxPercent)/100;
// calculate total amount for the purchase
total = subtotal + salesTax;
End Module
// Module to display the subtotal, sales tax and total purchase
amount
Module displayReceipt(Real subtotal, Real salesTax, Real
total)
Display "Subtotal : $",subtotal
Display "Sales tax: $",salesTax
Display "Total: $",total
End Module
//end of pseudocode