Johnny Utah owns a surf shop on the beach called “Point Break Surf Shop”. Johnny
ID: 3914984 • Letter: J
Question
Johnny Utah owns a surf shop on the beach called “Point Break Surf Shop”. Johnny sells surfboards in 3 three sizes: small (2 meters), medium (3 meters), and large (4 meters). The cost of one small surfboard is $175.00, one medium is $190.00, and one large is $200.00. Write a program that will make the surf shop operational. Your program should allow the user to do the following:
Buy any surfboard in any size and in any quanity.
At any time show the total number of surfboards of each size sold.
At any time show the total money made.
Your program must consist of "int main()" and at least the following functions:
void ShowUsage();
a function to show the user how to use the program.
void MakePurchase(int& iTotalSmall, int& iTotalMedium, int& iTotalLarge);
a function to sell surfboards.
void DisplayPurchase(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge);
function to show the number of surfboards of each size sold.
void DisplayTotal(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge);
a function to show the total amount of money made.
In your program you must define the functions as they are defined above. Do not change the signature (the name, parameters or the return value) or you will be marked down.
Your program should not use any global variables and the cost of the surfboards must be declared as named constants.
C:UsersJohnDocumentsVisual Studio 2017Projects'ITCS253aPointBreakSurfBoardsDe Welcome to my Johnny Utah's PointBreak Surf Shop* To show program usage S To purchase a surfboard press P To display current purchases press 'C To display tolal amount due press 'T' To quit the program press Q Please enter selection: c No purchases made yet. Please enter selection: t No purchases made yet. Please enter selection: p Please enter the quanity and type (S-small, M-medium, L-large) of surfboard you would like to purchase:3 m Please enter selection: c The total number of medium surfboards is 3 Please enter selection: p Please enter the quanity and type (S-small, M-medium, L-large) of surfboard you would like to purchase:2 1 Please enter selection: c The total number of medium surfboards is 3 The total number of large surfboards is 2 Please enter selection: t The total number of medium surfboards is 3 at a total of $570.00 The total number of large surfboards is 2 at a total of $400.e Amount due: $970.00 Please enter selection: q Thank you Press any key to continue . . .Explanation / Answer
#include<iostream>
#include<iomanip>
using namespace std;
//function declarations
void ShowUsage();
void MakePurchase(int& iTotalSmall, int& iTotalMedium, int& iTotalLarge);
void DisplayPurchase(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge);
void DisplayTotal(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge);
int main()
{
int iTotalSmall = 0, iTotalMedium=0, iTotalLarge=0;
char choice;
ShowUsage();
do
{
cout << " Please enter selction: ";
cin >> choice;
switch (choice)
{
case 's':
ShowUsage();
break;
case 'p':
MakePurchase(iTotalSmall, iTotalMedium, iTotalLarge);
break;
case 'c':
if (iTotalSmall == 0 && iTotalMedium == 0 && iTotalLarge == 0)
{
cout << "No purchases made yet ";
}
else
{
DisplayPurchase(iTotalSmall, iTotalMedium, iTotalLarge);
}
break;
case 't':
if (iTotalSmall == 0 && iTotalMedium == 0 && iTotalLarge == 0)
{
cout << "No purchases made yet ";
}
else
{
DisplayTotal(iTotalSmall, iTotalMedium, iTotalLarge);
}
break;
case 'q':
cout << "Thank you ";
break;
default:
cout << "Invalid selction , please check ";
break;
}
} while (choice != 'q');
}
//function defintions
void ShowUsage()
{
cout << "****************************************************************** ";
cout << "***** Welcome to my Johnny Utah's PointBreak Surf shop ***** ";
cout << "****************************************************************** ";
cout << " To show program usage 'S'" << endl;
cout << "To purchase a surfboard press 'P'" << endl;
cout << "To display current purchases press 'c'" << endl;
cout << "To display total amount due press 'T'" << endl;
cout << "To quit the program press 'Q'" << endl;
}
void MakePurchase(int& iTotalSmall, int& iTotalMedium, int& iTotalLarge)
{
int quantity;
char type;
cout << "Please enter the quantity and type(S=small, M=medium, L=large you would like to purchase: ";
cin >> quantity >> type;
switch (type)
{
case 's':
iTotalSmall+=quantity;
break;
case 'm':
iTotalMedium+=quantity;
break;
case 'l':
iTotalLarge+=quantity;
break;
default:
cout << "Invalid type , please check ";
break;
}
}
void DisplayPurchase(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge)
{
if (iTotalSmall > 0)
{
cout << "The total number of small surfboards is " << iTotalSmall << endl;
}
if (iTotalMedium > 0)
{
cout << "The total number of medium surfboards is " << iTotalMedium << endl;
}
if (iTotalLarge > 0)
{
cout << "The total number of large surfboards is " << iTotalLarge << endl;
}
}
void DisplayTotal(const int iTotalSmall, const int iTotalMedium, const int iTotalLarge)
{
cout<<fixed<<setprecision(2);
if (iTotalSmall > 0)
{
cout << "The total number of small surfboards is " << iTotalSmall << " at total of $"<< (double)iTotalSmall*175 <<endl;
}
if (iTotalMedium > 0)
{
cout << "The total number of medium surfboards is " << iTotalMedium << " at total of $" << (double)iTotalMedium * 190 <<endl;
}
if (iTotalLarge > 0)
{
cout << "The total number of large surfboards is " << iTotalLarge << " at total of $" << (double)iTotalLarge * 200<<endl;
}
double total = iTotalSmall * 175 + iTotalMedium * 190 + iTotalLarge * 200;
cout << "Amount due: $" << total << endl;
}
/*output
******************************************************************
***** Welcome to my Johnny Utah's PointBreak Surf shop *****
******************************************************************
To show program usage 'S'
To purchase a surfboard press 'P'
To display current purchases press 'c'
To display total amount due press 'T'
To quit the program press 'Q'
Please enter selction: c
No purchases made yet
Please enter selction: t
No purchases made yet
Please enter selction: p
Please enter the quantity and type(S=small, M=medium, L=large you would like to purchase: 3 m
Please enter selction: c
The total number of medium surfboards is 3
Please enter selction: p
Please enter the quantity and type(S=small, M=medium, L=large you would like to purchase: 2 l
Please enter selction: c
The total number of medium surfboards is 3
The total number of large surfboards is 2
Please enter selction: t
The total number of medium surfboards is 3 at total of $570.00
The total number of large surfboards is 2 at total of $400.00
Amount due: $970.00
Please enter selction: q
Thank you
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.