Question

In: Computer Science

A customer in a store is purchasing two items. Design a program using module pseudocode that...

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.

Solutions

Expert Solution

// 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


Related Solutions

A customer in a grocery store is purchasing three items. Write the pseudo code that will:...
A customer in a grocery store is purchasing three items. Write the pseudo code that will: • Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy...
create flowchart using Flowgorithm and Pseudocode for the following program example:   Design a program for Jones...
create flowchart using Flowgorithm and Pseudocode for the following program example:   Design a program for Jones College. The current tuition is $12,000 per year, and tuition is expected to increase by 5 percent each year. Display the tuition amount for each year over the next five years (use a looping structure).
A customer comes into a grocery store and buys 8 items. Write a PYTHON program that...
A customer comes into a grocery store and buys 8 items. Write a PYTHON program that asks for the name of the item and the price of each item, and then displays these on the screen. Refer to the print() and input() statements covered in the module. Do NOT use loops as it will be covered in later modules. Apples 2.10 Hamburger 3.25 Milk 3.49 Sugar 1.99 Bread 1.76 Deli Turkey 7.99 Pickles 3.42 Butter 2.79
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the data only if the customer is a high spender – a person who spent more than $1000 in the store. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.
Using Pseudocode: Design a program that allows the user to enter 20 names into a String...
Using Pseudocode: Design a program that allows the user to enter 20 names into a String array. Sort the array in ascending (alphabetical) order and display its contents.
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that...
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data: The lowest number in the array. The highest number in the array. The total of the numbers in the array. The average of the numbers in the array. PLEASE AND THANK YOU
Design a simple program, using pseudocode, to implement the recursive formula you found in part (a)...
Design a simple program, using pseudocode, to implement the recursive formula you found in part (a) to compute numbers in the Fibonacci sequence. Describe in detail how your program implements the recursive formula. You may find it useful to discuss how it through a concrete example such as F(8) = 21.
Discuss with the class the importance of program design (using pseudocode and/or flowcharts) when designing programs...
Discuss with the class the importance of program design (using pseudocode and/or flowcharts) when designing programs utilizing selection structures.
assume that the following pseudocode is executed in a program module main declare x = 1...
assume that the following pseudocode is executed in a program module main declare x = 1 declare sum = 0 declare max = 5 while ( x < max) Display "x is ", x set x = x + 1 set sum = s + x end while end module after the execution of this program the final value of x is_____ and the final value of sum is_____
A customer has purchased 15 items in a department store.
A customer has purchased 15 items in a department store. Write a code segment to read the unit price and the quantity of each these 15 items and to compute and print its price (which is the unit price times the quantity). Also compute and print average price of the 15 items.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT