Question: 1. Change the getRegular and getBoGo functions to value-returning functions. Test the program appropriately. #include #include using namespace std; //function prototypes void displayOptions ( );
1. Change the getRegular and getBoGo functions to value-returning functions. Test the program appropriately.
#include
#include
using namespace std;
//function prototypes
void displayOptions ( );
void getRegular (int windows, double price, double &total);
void getBoGo (int windows, double price, double &total);
int main ( )
{
int option = 0;
int numOrdered = 0;
double winPrice = 0.0;
double totalOwed = 0.0;
cout << fixed << setprecision(2);
displayOptions ( );
cout << "Pricing option? ";
cin >> option;
if (option == 1 || option == 2)
{
cout << "Number of windows: ";
cin >> numOrdered;
cout << "Price per window: ";
cin >> winPrice;
if (option == 1)
getRegular (numOrdered, winPrice, totalOwed);
else
getBoGo (numOrdered, winPrice, totalOwed);
// end if
cout << "Total owed-----> $" << totalOwed << end1 << end1;
}
else
cout << "Invalid option" << end1;
// end if
return 0;
} // end of main function
//*****function definitions*****
void displayOptions ( )
{
cout << "Pricing options:" << end1;
cout << "1 Regular pricing" << end1;
cout << "2 BOGO pricing" << end1;
} //end displayOptions
void getRegular (int windows, double price, double &total)
{
total = windows * price;
} // end getRegular function
void getBoGo (int windows, double price, double &total)
{
total = (windows / 2 + windows % 2) * price;
} // end getBoGo function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
