Help with a Coffee Shop program for class!

Hello! I have torn this website apart looking for help, but nothing has. I am currently in my first computer science class at uni, and I need help with this lab we are doing!

Here is the prompt:
Janice is starting a coffee shop in your town, and she has heard of your programming expertise. She is wanting you to develop a program that can help her keep track of cups of coffee she will sell at her store. The program must be able to accomplish the following:
1. Record/Sell a cup of coffee of the following sizes:
a. 9 fl oz: $1.75
b. 12 fl oz: $1.90
c. 15 fl oz: $2.00
2. Keep track of the total number of each type of cup sold.
3. Calculate the total amount of coffee sold in gallons.
a. 1 gallon = 128 fl oz
4. Calculate the total profits the store has made from the sale of coffee.
Note: Global variables (other than constants) are NOT permitted in this program. The creation and use of global variables will result in penalties.

I have been working for 2 days straight on this code, and I've come up short and am in need of any sort of help! Please let me know what you'd suggest I do or any changes I can make!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  #include <iostream>
#include <iomanip>
using namespace std;

void showMenu (){
    cout << " Coffee Shop Main Menu: " << endl;
    cout << " 1. Purchase a cup of coffee" << endl;
    cout << " 2. Display total number of cups of each size were sold" << endl;
    cout << " 3. Diplay total amount of coffee sold" << endl;
    cout << " 4. Display total shop profits" << endl;
    cout << " 5. Exit" << endl;
}

int main()
{
    // purchase, total cups, amount of coffee, profit
    int choice;
    int cupChoice;
    int small;
    int medium;
    int large;
    
    do{
    showMenu();
    cout << "Please choose an option."<< endl;
    cin >> choice;
    
    switch(choice){
        case 1:
            cout << " Which cup would you like to purchase? " << endl;
            cout << "1. Small (9oz): $1.75" << endl;
            cout << "2. Medium (12oz): $1.90" << endl;
            cout << "3. Large (15oz): $2.00" << endl;
            cin >> cupChoice;
            cout << "Thank you for your purchase!" << endl;
            break;
        case 2:
            break;


I know that I'll need cases for each menu option, but I am a little confused on how to get there. So far, this much of the code works. I need help with basically option 2 - 4. The end of my do while loop will end the program.
Last edited on
Something quick and dirty, and incomplete:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>

void mainMenu()
{
   std::cout << " Coffee Shop Main Menu: \n";
   std::cout << " 1. Purchase a cup of coffee\n";
   std::cout << " 2. Display total number of cups of each size were sold\n";
   std::cout << " 3. Diplay total amount of coffee sold\n";
   std::cout << " 4. Display total shop profits\n";
   std::cout << " 5. Exit\n";
}

int sizeMenu()
{
   std::cout << " Which cup would you like to purchase? \n";
   std::cout << "1. Small (9oz): $1.75\n";
   std::cout << "2. Medium (12oz): $1.90\n";
   std::cout << "3. Large (15oz): $2.00\n";
   int cupChoice;
   std::cin >> cupChoice;
   std::cout << "Thank you for your purchase!\n";

   return cupChoice;
}

int main()
{
   // purchase, total cups, amount of coffee, profit
   int choice { };
   int cupChoice { };
   int small { };
   int medium { };
   int large { };

   while (true)
   {
      mainMenu();
      std::cout << "Please choose an option.\n";
      std::cin >> choice;

      switch (choice)
      {
      case 1:
         cupChoice = sizeMenu();

         switch (cupChoice)
         {
         case 1:
            small++;
            break;

         case 2:
            medium++;
            break;

         case 3:
            large++;
            break;

         default:
            std::cout << "Wrong cup size!\n";
            break;
         }
         break;

      case 2:
         std::cout << "Cups sold:\nSmall: " << small
            << "\nMedium: " << medium
            << "\nLarge: " << large << '\n';
         break;

      case 3:
         break;

      case 4:
         break;

      case 5:
         return 0;

      default:
         std::cout << "Wrong menu choice!\n";
      }
   }
}

 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
1
 Which cup would you like to purchase?
1. Small (9oz): $1.75
2. Medium (12oz): $1.90
3. Large (15oz): $2.00
1
Thank you for your purchase!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
1
 Which cup would you like to purchase?
1. Small (9oz): $1.75
2. Medium (12oz): $1.90
3. Large (15oz): $2.00
2
Thank you for your purchase!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
1
 Which cup would you like to purchase?
1. Small (9oz): $1.75
2. Medium (12oz): $1.90
3. Large (15oz): $2.00
1
Thank you for your purchase!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
1
 Which cup would you like to purchase?
1. Small (9oz): $1.75
2. Medium (12oz): $1.90
3. Large (15oz): $2.00
3
Thank you for your purchase!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
6
Wrong menu choice!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
1
 Which cup would you like to purchase?
1. Small (9oz): $1.75
2. Medium (12oz): $1.90
3. Large (15oz): $2.00
5
Thank you for your purchase!
Wrong cup size!
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
2
Cups sold:
Small: 2
Medium: 1
Large: 1
 Coffee Shop Main Menu:
 1. Purchase a cup of coffee
 2. Display total number of cups of each size were sold
 3. Diplay total amount of coffee sold
 4. Display total shop profits
 5. Exit
Please choose an option.
5
From Fury's code then option 3) is easy. You have the number of each size and the volume of each size - which gives the total volume sold in fl oz. You can then convert this value to gallons as you are given the conversion factor.

However, for option 4) to calculate the profit. You know the price sold per cup, the number of cups etc so you know the total amount of sales. What doesn't seem to be given is the cost of the coffee to calculate the profit. Profit is sales - cost. You have the sales value but not the cost. ???
I think my professor is looking for total sales, but used profit instead? I'm not too sure, he only gives us the labs and then doesn't answer questions about them
Topic archived. No new replies allowed.