#include<iostream> #include <cmath> #include <iomanip> using namespace std; void
ID: 3564735 • Letter: #
Question
#include<iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void BuyCoffee1(char&, double, double, double);
void instructionrerun();
void BuyCoffee(int type,int amount);
void ShowCoffeeSold();
void ShowProfit();
int main ()
{
char size;
double smallCoffee=1.75;
double mediumCoffee=1.75;
double largeCoffee=1.75;
double amount;
int smallsSold=0;
int mediumsSold=0;
int largesSold=0;
double profit;
cout<<" Welcome to Jason's Coffee Shop"<<endl;
instructionrerun();
cout<<"Coffee Price:"<<endl;
cout<<"Coffee Size: Small: Medium: Large:"<<endl;
cout<<"Price of each coffee cup size:1.75:1.90:2.00"<<endl;
BuyCoffee1(size,smallCoffee,mediumCoffee,largeCoffee);
cout<<"Show Profit and Total COffee Sold"<<endl;
ShowCoffeeSold();
ShowProfit();
return 0;
}
void instructionrerun()
{
cout<<"Intructions"<<endl;
cout<<"Select Coffee Cup Size"<<endl;
cout<<"Select Number of cups"<<endl;
}
void BuyCoffee1(char& size, double smallCoffee, double mediumCoffee, double largeCoffee)
{
double smallPrice=1.75;
double mediumPrice=1.90;
double largePrice=2.00;
int smallsSold =0;
int mediumsSold=0;
int largesSold=0;
double amount;
char again,fixed,character;
cout<<"Cup Size";
cout<<"Small Cup"<<smallCoffee<<endl;
cout<<"Medium Cup"<<mediumCoffee<<endl;
cout<<"Large Cup"<<largeCoffee<<endl;
cout<<"A for Buy Coffee"<<endl;
cout<<"B for Show Coffee"<<endl;
cout<<"C for Show Profit"<<endl;
cout<<"X to skip"<<endl;
cout<<"Enter your choice"<<endl;
character=getchar();
switch(character)
{
int type, amount;
case'A':
BuyCoffee(type,amount);
break;
case'B':
ShowCoffeeSold();
break;
case'C':
ShowProfit();
break;
default:
cout<<"NO choice";
}
}
void BuyCoffee(int type, int amount)
{
double smallPrice=1.75;
double mediumPrice=1.90;
double largePrice=2.00;
int smallsSold =0;
int mediumsSold=0;
int largesSold=0;
double profit;
cout<<"Choose a size: ";
cout<<"1 for Small Coffee"<<endl;
cout<<"2 for Medium Coffee"<<endl;
cout<<"3 for Large Coffee"<<endl;
cout<<"4 to Skip"<<endl;
cout<<"Enter your type";
cin>>type;
switch(type)
{
case 1:
cout<<"The size you choose is Small"<<endl;
cout<<"How many?";
cin>>amount;
profit +=smallPrice*amount;
smallsSold +=amount;
cout<<amount<<"Small Coffee(s) brought for $"<<smallPrice *amount;
break;
case 2:
cout<<"The size you choose is Medium"<<endl;
cout<<"How many?";
cin>>amount;
profit +=mediumPrice*amount;
mediumsSold +=amount;
cout<<amount<<"Small Coffee(s) brought for $"<<mediumPrice *amount;
break;
case 3:
cout<<"The size you choose is Large"<<endl;
cout<<"How many?";
cin>>amount;
profit +=largePrice*amount;
largesSold +=amount;
cout<<amount<<"Small Coffee(s) brought for $"<<largePrice *amount;
break;
default:
cout<<"no choice";
}
char again;
if (amount<=0)
cout<<endl<<"Thank You for your order";
else
cout<<"Would you like to add into your order(Y/N)?";
cin>>again;
if (again=='Y' || again =='y')
{
cout<<"select"<<endl;
BuyCoffee(type, amount);
}
else (again == 'N'||again=='n')
{
cout<<"Thanks!Good Bye!";
}
}
void ShowCoffeeSold()
{
double smallsSold, largesSold, mediumsSold;
cout<<"Coffee Sold";
cout<<"TypeAmount";
cout<<"Small "<<smallsSold<<" ";
cout<<"Medium "<<mediumsSold<<" ";
cout<<"Large "<<largesSold<<" ";
cout<<"Total "<<smallsSold+largesSold+mediumsSold<<" ";
}
void ShowProfit()
{
double smallPrice,smallsSold,mediumPrice,largePrice,
largesSold,mediumsSold;
cout<<"Profit";
cout<<"Profit some small coffees:"<<smallsSold*smallPrice<<" ";
cout<<"Profit some medium coffees:"<<mediumsSold*mediumPrice<<" ";
cout<<"Profit some large coffees:"<<largesSold*largePrice<<" ";
cout<<"Total Profit: "<<(smallsSold*smallPrice)+(mediumsSold*mediumPrice)+
largesSold*largePrice);
}
Explanation / Answer
#include<iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define smallPrice 1.75
#define mediumPrice 1.90
#define largePrice 2.00
#define small 9
#define medium 12
#define large 15
void showInstruction();
void BuyCoffee(int& smallsSold,int& mediumsSold,int& largesSold);
void ShowCoffeeSold(int smallsSold,int mediumsSold,int largesSold);
void ShowTotalCoffee(int smallsSold,int mediumsSold,int largesSold);
void ShowProfit(int smallsSold,int mediumsSold,int largesSold);
int main ()
{
char option='y',choice='y';
int smallsSold =0;
int mediumsSold=0;
int largesSold=0;
cout<<" Welcome to Jason's Coffee Shop"<<endl;
cout<<" Please find the intructions to use the program :"<<endl;
cout<<"----------------------------------------------------"<<endl;
//Input value from user
while(choice='y'||choice=='Y'){
showInstruction();
cin>>option;
switch(option)
{
case'A':
case 'a':
BuyCoffee(smallsSold,mediumsSold,largesSold);
break;
case'B':
case 'b':
ShowCoffeeSold(smallsSold,mediumsSold,largesSold);
break;
case'C':
case 'c':
ShowTotalCoffee(smallsSold,mediumsSold,largesSold);
break;
case'D':
case 'd':
ShowProfit(smallsSold,mediumsSold,largesSold);
break;
default:
cout<<"NO choice";
}
cout<<"Would you like to add into your order(Y/N)?";
cin>>choice;
}
cout<<"Thanks!Good Bye!";
return 0;
}
void showInstruction()
{
cout<<"Input following to choose option :"<<endl;
cout<<"A - To Buy coffee in any size and in any number of cups"<<endl;
cout<<"B - To show the total number of cups of each size sold "<<endl;
cout<<"C - To show the total amount of coffee sold."<<endl;
cout<<"D - To show the total money made"<<endl;
cout<<"Input choice:"<<endl;
}
void BuyCoffee(int& smallsSold,int& mediumsSold,int& largesSold)
{
int count,type;
cout<<"Choose a coffee size to buy : "<<endl;
cout<<"1 for Small Coffee"<<endl;
cout<<"2 for Medium Coffee"<<endl;
cout<<"3 for Large Coffee"<<endl;
cout<<"4 to Skip"<<endl;
cout<<"Enter your type:";
cin>>type;
switch(type)
{
case 1:
cout<<"The size you choose is Small"<<endl;
cout<<"Enter the count :";
cin>>count;
smallsSold+=count;
break;
case 2:
cout<<"The size you choose is Medium"<<endl;
cout<<"Enter the count :";
cin>>count;
mediumsSold+=count;
break;
case 3:
cout<<"The size you choose is Large"<<endl;
cout<<"Enter the count :";
cin>>count;
largesSold+=count;
break;
default:
cout<<"No choice";
}
}
void ShowCoffeeSold(int smallsSold,int mediumsSold,int largesSold)
{
cout<<"Coffee Sold";
cout<<"TypeAmount";
cout<<"Small "<<smallsSold<<endl;
cout<<"Medium "<<mediumsSold<<endl;
cout<<"Large "<<largesSold<<endl;
}
void ShowTotalCoffee(int smallsSold,int mediumsSold,int largesSold){
cout<<"Total Amount of coffee sold "<<smallsSold+largesSold+mediumsSold<<endl;
}
void ShowProfit(int smallsSold,int mediumsSold,int largesSold)
{
cout<<"Total amount made ";
cout<<"Profit some small coffees:"<<smallsSold*smallPrice<<endl;
cout<<"Profit some medium coffees:"<<mediumsSold*mediumPrice<<endl;
cout<<"Profit some large coffees:"<<largesSold*largePrice<<endl;
cout<<"Total Profit: "<<(smallsSold*smallPrice)+(mediumsSold*mediumPrice)+(largesSold*largePrice)<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.