Writing coffee shop simulation

I'm having a few issues with this coffee shop simulation. Every time I run it it'll go till i get to the menu and then most selections I make give me a blank command prompt. Hopefully someone can see what I'm missing.


#include<iostream>
#include<iomanip>

using namespace std;

//Declaring the constants.
const double SMALL_CUP = 1.75;
const double MED_CUP = 1.90;
const double LARGE_CUP = 2.00;
const double SMALL_SIZE = 9;
const double MED_SIZE = 12;
const double LARGE_SIZE = 15;

//declaring the user defined functions.
void menu(int& choice);
double coffeePurchase(int);
void cupsSold(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);
void coffeeSold(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);
void cashMade(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);

int main()
{
int choice;
menu(choice);
system("pause");
return 0;
}

//function to get the coffee purchase info and calculate total sold and cup counts for each size.
double coffeePurchase(int)
{
int size, cupNum;
int cupCountSmall = 0;
int cupCountMed = 0;
int cupCountLarge = 0;
double price = 0;
double totalSold = 0;

cout << "What size of coffee do you want?(input a single number to select. " << endl;
cout << "1. Small(9oz) for $1.75 each." << endl;
cout << "2. Medium(12oz) for $1.90 each." << endl;
cout << "3. Large(15oz) for $2.00 each." << endl;
cin >> size;
cout << "How many " << size << " cups do you want?" << endl;
cin >> cupNum;

if (size == 1)
{
cupCountSmall += cupNum;
price = SMALL_CUP * cupNum;
}
else if (size == 2)
{
cupCountMed += cupNum;
price = MED_CUP * cupNum;
}
else if (size == 3)
{
cupCountLarge += cupNum;
price = LARGE_CUP * cupNum;
}
cout << "The price of your purchase is: " << price << endl;
totalSold += price;
return totalSold;
return cupCountLarge;
return cupCountMed;
return cupCountSmall;
}

//function for the selection menu.
void menu(int& choice)
{
cout << "What would you like to do?(input a single number to select)" << endl;
cout << "1. Buy coffee." << endl;
cout << "2. Show the total of each coffee cup size sold." << endl;
cout << "3. Show the total amount of coffee sold in ounces." << endl;
cout << "4. Show the amount of money made." << endl;
cout << "5. Exit the program." << endl;
cin >> choice;
do
{
switch (choice)
{
case 1:
double coffeePurchase(int);
break;
case 2:
void cupsSold(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);
break;
case 3:
void coffeeSold(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);
break;
case 4:
void cashMade(double& cupCountSmall, double& cupCountMed, double& cupCountLarge);
break;
case 5:
return;
default:
cout << "Invalid input. Please input something else." << endl;
}
} while (choice != 5);
}

//function to output the # of each cup size sold.
void cupsSold(double cupCountSmall, double cupCountMed, double cupCountLarge)
{
cout << "The number of small cups sold is: " << cupCountSmall << endl;
cout << "The number of medium cups sold is: " << cupCountMed << endl;
cout << "The number of large cups sold is: " << cupCountLarge << endl;
}

//function to output the # of ounces of cofffee sold.
void coffeeSold(double cupCountSmall, double cupCountMed, double cupCountLarge)
{
double totalOunces = 0;

totalOunces = cupCountSmall * SMALL_SIZE + cupCountMed * MED_SIZE + cupCountLarge * LARGE_SIZE;
cout << "Total ounces of coffee sold is: " << totalOunces << endl;
}

//function to output the amount of dosh made.
void cashMade(double cupCountSmall, double cupCountMed, double cupCountLarge)
{
double totalCash = 0;

totalCash = cupCountSmall * SMALL_CUP + cupCountMed * MED_CUP + cupCountLarge * LARGE_CUP;
cout << "Total money made is: $" << setprecision(2) << fixed << totalCash << endl;
}
Last edited on
closed account (48T7M4Gy)
1
2
3
case 1:
double coffeePurchase(int);
break;

Who'd you copy this off?
Last edited on
Who'd you copy this off?
\

What do you mean? Is that really bad code or code so good he must've copied it?
closed account (48T7M4Gy)
Is that really bad code or code so good he must've copied it?

The 'or' in your question fails on two counts, the first relating to mutual exclusivity and the second relating to an incompleteness in the menu of choices you provide.
Hopefully someone can see what I'm missing.

The first thing you're missing is code tags. Please edit your post to use them, to make your code more readable:

http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.