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.
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;
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.