(C++ program)code jason opened a coffe shop at the beach and sells coffe in thre
ID: 3667241 • Letter: #
Question
(C++ program)code
jason opened a coffe shop at the beach and sells coffe in three sizes:small(9oz),medium (12oz),and large (15oz).the cost of one small cup is $1.75,one medium cup is $1.90,and large cup is $2.00. write a menu-driven program that will make the coffe shop operational .your program should allow the user to do the following :
a. Buy coffe in any size and in any number of cups.
b. At any time show the total number of cups of each size sold .
c.At any time show thr total amount of coffe sold.
d. At any time show thr total money made.
Explanation / Answer
#include<cstdlib>
#include<iostream>
using namespace std;
void menu(int&);
double sizeChoice(int&);
double cream();
double sugar();
int main()
{
double totalCost = 0;
int sizeCoffee = 1;
char addToOrder = 'y';
int smallSold =0;
int mediumSold = 0;
int largeSold = 0;
while (addToOrder == 'y' || addToOrder == 'Y')
{
menu(sizeCoffee);
totalCost += sizeChoice(sizeCoffee);
cout << "Would you like to add to your order (Y/N):";
cin >> addToOrder;
}
cout << endl << "Reciept: " << endl;
cout << "Total Cost: " << totalCost << endl;
cout << endl << endl;
system("Pause");
return 0;
}
void menu(int &sizeCoffee)
{
do
{
cout << "What size coffee would you like?" << endl;
cout << "Press 1 for small." << endl;
cout << "Press 2 for medium." << endl;
cout << "Press 3 for large." << endl;
cout << "Your selection: ";
cin >> sizeCoffee;
if (sizeCoffee < 1 || sizeCoffee > 3) cout << "INVALID SELECTION" << endl;
} while (sizeCoffee < 1 || sizeCoffee > 3);
}
double sizeChoice(int &sizeCoffee)
{
const double SMALL_CUP = 1.75;
const double MEDIUM_CUP = 1.90;
const double LARGE_CUP = 2.00;
switch (sizeCoffee)
{
case 1:
return SMALL_CUP;
break;
case 2:
return MEDIUM_CUP;
break;
case 3:
return LARGE_CUP;
default:
return 0;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.