OEIECTIVES Review the dowhile looo Review the witch statemen

OEIECTIVES: -Review the do-while looo -Review the witch statement -Review how to format the output in columns -How to createand call the user-defined function: -Apply reference paramenter to user-defined functon

Solution

Here is the code for you:

#include <iostream>
using namespace std;
int main()
{
int smallCups = 0, mediumCups = 0, largeCups = 0, choice, numOfCups, cupSize;
double cupCost;
const double SMALL_PRICE = 1.19;
const int SMALL_OZ = 8;
const double MEDIUM_PRICE = 1.49;
const int MEDIUM_OZ = 12;
const double LARGE_PRICE = 1.89;
const int LARGE_OZ = 16;
while(true)
{
cout<<\"1. Buy Coffee.\"<<endl;
cout<<\"2. Number of cups of each size.\"<<endl;
cout<<\"3. Amount of coffee sold.\"<<endl;
cout<<\"4. Total money made.\"<<endl;
cout<<\"5. Exit.\"<<endl;
cout<<\"Enter your choice: \";
cin>>choice;
switch(choice)
{
case 1: cout<<\"1. Small (8oz) 2. Medium (12oz) 3. Large(16oz).\"<<endl;
       cout<<\"Select your cup size: \";
       cin>>cupSize;
       cout<<\"Enter the number of cups: \";
       cin>>numOfCups;
       if(cupSize == 1)
       {
       smallCups += numOfCups;
       cupCost = SMALL_PRICE;
       }
       else if(cupSize == 2)
       {
       mediumCups += numOfCups;
       cupCost = MEDIUM_PRICE;
       }
       else if(cupSize == 3)
       {
       largeCups += numOfCups;
       cupCost = LARGE_PRICE;
       }
       cout<<\"Here is your coffe... You should pay a total of: \"<< cupCost * numOfCups<<endl;
       break;
case 2: cout<<\"Small cups sold: \"<<smallCups<<\".\ Medium cups sold: \"<<mediumCups<<\".\ Large cups sold: \"<<largeCups<<\".\ \"; break;
case 3: cout<<\"Total amount of coffee sold: \"<< smallCups * SMALL_OZ + mediumCups * MEDIUM_OZ + largeCups * LARGE_OZ<<\"oz.\"<<endl; break;
case 4: cout<<\"Total money made: \"<<smallCups * SMALL_PRICE + mediumCups * MEDIUM_PRICE + largeCups * LARGE_PRICE<<\"$\"<<endl; break;
case 5: return 0;
default: cout<<\"Invalid menu option.\"<<endl;
}
}
}

 OEIECTIVES: -Review the do-while looo -Review the witch statement -Review how to format the output in columns -How to createand call the user-defined function:
 OEIECTIVES: -Review the do-while looo -Review the witch statement -Review how to format the output in columns -How to createand call the user-defined function:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site