(wrtie a C++ )Jason opened a coffee shop at the beach and sells coffee in three
ID: 3759858 • Letter: #
Question
(wrtie a C++ )Jason opened a coffee shop at the beach and sells coffee 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 one large cup is $2.00. Write a menu-driven program that will make the coffee shop operational. Your program should allow the user to do the following:
a.Buy coffee 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 the total amount of coffee sold.
d. At any time show the total money made.
Complete the analysis and design started below, implement the design, compile and test your code, and turn in your completed analysis and design, and your source code.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
#include<string.h>
char menu()
{
int c;
char ans;
cout<<" a.Buy coffee in any size and in any number of cups.";
cout<<" b.At any time show the total number of cups of each size sold.";
cout<<" c.At any time show the total amount of coffee sold.";
cout<<" d. At any time show the total money made.";
cout<<" e.Quit";
cout<<" Enter your choise[a-e]";
cin>>ans;
return ans;
}
void main()
{
char c;
int cup[3],n;
cup[0]=0;
cup[1]=0;
cup[2]=0;
char size[10];
while(1)
{
c=menu();
switch(c)
{
case 'a':
cout<<"Enter size of cups";
cin>>size;
cout<<"Enter number of cups";
cin>>n;
if(strcmp(size,"small")==0)
{
cup[0]=cup[0]+n;
}
if(strcmp(size,"medium")==0)
{
cup[1]=cup[1]+n;
}
if(strcmp(size,"large")==0)
{
cup[2]=cup[2]+n;
}
break;
case 'b':
cout<<" Small size of cups"<<cup[0];
cout<<" medium size of cups"<<cup[1];
cout<<" large size of cups"<<cup[2];
break;
case 'c':
cout<<" Amount of Small size of cups"<<cup[0]*1.75;
cout<<" Amount of medium size of cups"<<cup[1]*1.9;
cout<<" Amount of large size of cups"<<cup[2]*2.0;
break;
case 'd':
cout<<" Total money"<<cup[0]*1.75+cup[1]*1.9+cup[2]*2.0;
break;
case 'e':
return;
}
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.