Supermarket Pricing Example
Problem analysis: 4 main subtasks
- print usage statement
- input the data
- compute the retail price of the item
- output the results
//Postcondition: Description of program is written on the screen.
void get_input(double& cost, int& turnover);
//Precondition: User is ready to enter values correctly.
//Postcondition: The value of cost has been set to the
//wholesale cost of one item. The value of turnover has been
//set to the expected number of days until the item is sold.
double price(double cost, int turnover);
//Precondition: cost is the wholesale cost of one item.
//turnover is the expected number of days until sale of the item.
//Returns the retail price of the item.
void give_output(double cost, int turnover, double price);
//Precondition: cost is the wholesale cost of one item; turnover is the
//expected time until sale of the item; price is the retail price of the item.
//Postcondition: The values of cost, turnover, and price have been
double wholesale_cost, retail_price;
get_input(wholesale_cost, shelf_time);
retail_price = price(wholesale_cost, shelf_time);
give_output(wholesale_cost, shelf_time, retail_price);