Then it should determine and display the unit price (the price per ounce) of that item and the total cost of the amount purchased. You will need the following variables:
ItemName (a String) Pounds (a Float) Ounces (a Float)
PoundPrice (a Float) TotalPrice (a Float) UnitPrice (a Float)
You will need the following formulas:
UnitPrice = PoundPrice/16
TotalPrice = PoundPrice*(Pounds + Ounces/16)
Process: 1. Display a Title of Program 2. Prompt for Item Name 3. Prompt for Item Price 4. Prompt for Weight in Pounds 5. Prompt for Ounces 6. Convert Pounds to Ounces and add to Input Ounces 7. Divide Total Price by Ounces 8. Display Price per Ounce
Input:
Item Name (string: ItemName) Item Price (Real: Price) Item Weight in Pounds (Integer: Pounds) Fraction of Ounces (Integer: Ounces)
Output: Unit Price (Real: UnitPrice)
Design
Main Module
Declare itemName as String Declare price as real Declare pounds as integer Declare ounces as integer Declare unitPrice as real Write “Unit Price Program” Write “This program computes the unit price for an item” Call Input Data Module Call Perform Calculations Module Call Output Results Module End Program
End Main Module
Input Data Module
Write “What is the item’s name” Input itemName Write “How much does the items cost?” Input price Write “What is the weight in pounds (no fractions)?” Input pounds Write “What are the fractional ounces?” Input ounces
End Input Data Module
Perform Calculations Module
Set ounces = pounds/16 + ounces unitPrice = price/ounces
End Perform Calculations Module
Output Results Module
Write “The item is,” itemName