Checkpoint Chapter 2 Programming Problem

Only available on StudyMode
  • Download(s) : 481
  • Published : September 28, 2012
Open Document
Text Preview
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. Analysis

Process:
1.Display program title.
2.Prompt for item name.
3.Prompt for price of item.
4.Prompt for weight of item in pounds.
5.Prompt for weight of item in ounces.
6.Convert pounds to ounces then add it to input ounces.
7.Dived price total by ounces.
8.Display price per ounce.

Input:
Item name (String: ItemName)
Item Price (Real: Price)
Item Weight in pounds (integer: Pounds)
Item Weight in ounces (integer: Ounces)

Output:

Unit Price (real: UnitPrice)

Design
Main Module

Declare ItemName as string
Declare ItemPrice as real
Declare ItemWeightLb as integer
Declare ItemWeight Oz as integer
Declare UnitPrice as real
Write “ Welcome User”
Write “ This program computes an unit items price (In Ounces)” Call Input Data Module
Call Perform Calculations Module
Call Output Results Module
End Program

End Main Module

Input Data Module

Write “ What is Items name?”
Input ItemName

Write “ What is price of Item?”
Input ItemPrice

Write “What is Item weight in pounds?”
Input ItemWeightLB

Write “ What does item weigh converted into ounces?” Input ItemWeightOz

End Input Data Module

Perform Calculations Module

Declare TotalOz as real
Set ounces = 16 + pounds + ounces
UnitPrice = PoundPrice/16
TotalPrice = PoundPrice*(Pounds + Ounces/16)

End Perform Calculations Module

Output Results Module

Write “Item is” : ItemName
Write “Total Price of item is” : ItemPrice
Write “ Unit price of item is” : UnitPrice/Oz

End Output Results Module

End Program
tracking img