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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#include <iostream>
#include <iomanip>
using std::cout; using std::cin; using std::endl;
//global constants for coffee prices and ounces
const double priceSmallCoffee = 1.75;
const double priceMediumCoffee = 1.90;
const double priceLargeCoffee = 2.00;
const int ouncesSmallCoffee = 9;
const int ouncesMediumCoffee = 12;
const int ouncesLargeCoffee = 15;
//function prototypes
int storeMenu();
void coffeeSales(int&, int&, int&);//function takes parameters by reference so it can update daily totals
int coffeeMenu();
int getCups();
double totalSale(int,int,int);
void coffeeByCupSize(int,int,int);
void coffeeByOunces(int,int,int);
void coffeeByDollars(int,int,int);
int main()
{
bool storeOpen = true;
int mainChoice = 0;
int todaySales_SmallCups = 0;
int todaySales_MediumCups = 0;
int todaySales_LargeCups = 0;
do
{
mainChoice = storeMenu();
switch(mainChoice)
{
case 1: coffeeSales(todaySales_SmallCups,todaySales_MediumCups,todaySales_LargeCups);
break;
case 2: coffeeByCupSize(todaySales_SmallCups,todaySales_MediumCups,todaySales_LargeCups);
break;
case 3: coffeeByOunces(todaySales_SmallCups,todaySales_MediumCups,todaySales_LargeCups);
break;
case 4: coffeeByDollars(todaySales_SmallCups,todaySales_MediumCups,todaySales_LargeCups);
break;
case 5: cout << "help function here" << endl;
break;
case 6: storeOpen = false;
break;
default: cout << "Shouldn't ever see this"; break;
}
}while(storeOpen != false);
cout << "Coffee Shop is now closed. Goodbye!" << endl;
return 0;
}
int storeMenu()
{
int choice;
cout << "Welcome to the Coffee Shop" << endl;
cout << "**************************" << endl;
cout << "1. Sell Coffee" << endl;
cout << "2. Coffee Sold Today - By Cup Size" << endl;
cout << "3. Coffee Sold Today - By Ounces" << endl;
cout << "4. Coffee Sold Today - By Dollars" << endl;
cout << "5. Help" << endl;
cout << "6. Close Store" << endl;
cout << "\nEnter selection (1-6): " << endl;
cin >> choice;
while (!(choice >= 1 && choice <= 6))
{
cout << "Invalid Selection - Please re-enter: ";
cin >> choice;
}
return choice;
}
void coffeeSales(int& todaySmall, int& todayMedium, int& todayLarge)
{
int cups = 0;
int thisSale_SmallCups = 0;
int thisSale_MediumCups = 0;
int thisSale_LargeCups = 0;
double thisSale_total = 0.0;
int coffeeChoice = 0;
do
{
coffeeChoice = coffeeMenu();
switch(coffeeChoice)
{
case 1: cups = getCups();
thisSale_SmallCups += cups;
break;
case 2: cups = getCups();
thisSale_MediumCups += cups;
break;
case 3: cups = getCups();
thisSale_LargeCups += cups;
break;
case 4: thisSale_total = totalSale(thisSale_SmallCups,thisSale_MediumCups,thisSale_LargeCups);
cout << "\nTotal price is $" << thisSale_total << endl;
//increment daily totals with the current sale
todaySmall += thisSale_SmallCups;
todayMedium += thisSale_MediumCups;
todayLarge += thisSale_LargeCups;
break;
}
}while (coffeeChoice != 4);
}
int coffeeMenu()
{
int choice = 0;
cout << "Coffee Menu" << endl;
cout << "***********" << endl;
cout << "1. Small" << endl;
cout << "2. Medium" << endl;
cout << "3. Large" << endl;
cout << "4. End Sale" << endl;
cout << "Enter Selection (1-4):";
cin >> choice;
while (!(choice >= 1 && choice <=4))
{
cout << "Invalid Selection - Please re-enter: ";
cin >> choice;
}
return choice;
}
int getCups()
{
int cups = 0;
cout << "\nHow many cups?: ";
cin >> cups;
cout << endl;
return cups;
}
double totalSale(int small,int medium,int large)
{
if (small>0)
{
cout << "\nSmall Cups: " << small << " at $" << priceSmallCoffee << " each: " << small*priceSmallCoffee << endl;
}
if (medium>0)
{
cout << "Medium Cups: " << medium << " at $ " << priceMediumCoffee << " each: " << medium*priceMediumCoffee << endl;
}
if (large>0)
{
cout << "Large Cups: " << large << " at $" << priceLargeCoffee << " each: " << large*priceLargeCoffee << endl;
}
return (small*priceSmallCoffee) + (medium*priceMediumCoffee) + (large*priceLargeCoffee);
}
void coffeeByCupSize(int small,int medium,int large)
{
cout << "Coffee Sold Today - Small Cups: " << small << endl;
cout << "Coffee Sold Today - Medium Cups: " << medium << endl;
cout << "Coffee Sold Today - Large Cups: " << large << endl;
}
void coffeeByOunces(int small,int medium,int large)
{
cout << "Coffee Sold Today - Total Ounces: " << (small*ouncesSmallCoffee) + (medium*ouncesMediumCoffee) + (large*ouncesLargeCoffee) << endl;
}
void coffeeByDollars(int small,int medium,int large)
{
cout << "Coffee Sold Today - Total Dollars: $" << (small*priceSmallCoffee) + (medium*priceMediumCoffee) + (large*priceLargeCoffee) << endl;
}
|