Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Jason opened a coffee shop at the beach and sells coffee in three sizes: small (

ID: 3802216 • Letter: J

Question

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:

Buy coffee in any size and in any number of cups.

At any time show the total number of cups of each size sold.

At any time show the total amount of coffee sold.

At any time show the total money made.

The buy coffee option allows the customer to select the number of cups in each of the sizes they want to order and display a receipt for that order. The other three options would be used by the owner to check on the status of the shop during the day.

Design a modular program to implement this program. Pay attention to the user interface. Try to minimize the number of times the user is required to touch the keyboard.

Turn in: structure chart, source code and output showing test results (screen shot or picture)

Checklist:

Structure chart included.

File name included as comment at top of source file

IPO chart included as comments following the file name

Variable names are meaningful

IPO charts for functions incorporated as comments before each function

Program compiles

Program prompts for input and validates as needed.

Program output is formatted neatly

Program produces correct results

Program is thoroughly tested with test output included

Explanation / Answer

Here is the C++ 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.75;
const int SMALL_OZ = 9;
const double MEDIUM_PRICE = 1.90;
const int MEDIUM_OZ = 12;
const double LARGE_PRICE = 2.00;
const int LARGE_OZ = 15;
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 (9oz) 2. Medium (12oz) 3. Large(15oz)."<<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;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote