This action might not be possible to undo. Are you sure you want to continue?
Check Point: Chapter 2 Programming Problem
The manager of the Super Supermarket would like to be able to compute the unit price for products sold there. To do this, the program should input the name and price of an item and its weight in pounds and ounces. It should then determine and display the unit price (the price per ounce) of the item.
Main Module Declare ItemName as string Declare ItemPrice as real Declare ItemWeightLb as real Declare ItemWeightOz as real Declare UnitPrice as real Write ³Welcome.´ Write ³This program computes an item¶s unit price (price per ounce).´ Call Input Data Module Call Perform Calculations Module Call Output Results Module End Program Input data module Write ³What is the item¶s name?´ Input ItemName Write ³What is the item¶s price?´ Input ItemPrice Write ³You will now enter the item¶s weight (two steps).´ Write ³How many pounds does the item weigh (excluding ounces over nearest pound)?´ Input ItemWeightLb Write ³Now how many ounces?´ Input ItemWeightOz End Input data module
Perform calculations module Declare TotalOz as real Set TotalOz = ItemWeightLb * 16 + ItemWeightOz Set UnitPrice = ItemPrice / TotalOz End Perform calculations module
Output results module Write ³The item name is: ´ ; ItemName Write ³The price per ounce is : $´ ; UnitPrice End Output results module