//Determines the retail price of an item according to //the pricing policies of the Quick-Shop supermarket chain. #include const double LOW_MARKUP = 0.05; //5% const double HIGH_MARKUP = 0.10; //10% const int THRESHOLD = 7; //Use HIGH_MARKUP if do not //expect to sell in 7 days or less. void introduction( ); //Postcondition: Description of program is written on the screen. void get_input(double& cost, int& turnover); //Precondition: User is ready to enters values correctly. //Postconditions: 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); //Preconditions: cost is the wholesale cost of one item. //turnover is the expect number of days until sale of the item. //Returns the retail price of the item. void give_output(double cost, int turnover, double price); //Preconditions: cost is the wholesale cost of one item; turnover is the //expect time until sale of the item; price is the retail price of the item. //Postconditions: The values of cost, turnover, and price have been //written to the screen. int main( ) { double wholesale_cost, retail_price; int shelf_time; introduction( ); get_input(wholesale_cost, shelf_time); retail_price = price(wholesale_cost, shelf_time); give_output(wholesale_cost, shelf_time, retail_price); return 0; } //Uses iostream.h: void introduction( ) { cout << "This program determines the retail price for\n" << "an item at a Quick-Shop supermarket store.\n"; } //Uses iostream.h: void get_input(double& cost, int& turnover) { cout << "Enter the wholesale cost of item $"; cin >> cost; cout << "Enter the expected number of days until sold: "; cin >> turnover; } //Uses iostream.h: void give_output(double cost, int turnover, double price) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "Wholesale cost = $" << cost << endl << "Expected time until sold = " << turnover << " days" << endl << "Retail price= $" << price << endl; } //Uses defined constants LOW_MARKUP, HIGH_MARKUP, and THRESHOLD: double price(double cost, int turnover) { if (turnover <= THRESHOLD) return ( cost + (LOW_MARKUP * cost) ); else return ( cost + (HIGH_MARKUP * cost) ); }