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 179 180 181 182
|
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include <cctype>
#include <iomanip>
using namespace std;
void ResetValues(int &iCS, int &iCC, int &mS, int &totalICS, int &totalICC, int &totalMS)
{
iCS = 0;
iCC = 0;
mS = 0;
totalICS = 0;
totalICC = 0;
totalMS = 0;
}
void CashOut(int totalICS, int totalICC, int totalMS)
{
ofstream fout;
fout.open ("receipt.dat", ios::app);
fout << totalICS << "#" << totalICC << "#" << totalMS << "#" << endl;
fout.close();
const float SUNDAES_COST = 2.50;
const float CONES_COST = 1.10;
const float SHAKES_COST = 2.75;
const float TAX = .06;
float subTotal = totalICS * SUNDAES_COST + totalICC * CONES_COST + totalMS * SHAKES_COST;
float totalTax = subTotal * TAX;
float totalCost = subTotal + totalTax;
ofstream foutt;
foutt.open ("receipt.rpt", ios::app);
foutt << "Number of Sundaes:" << totalICS << "@ $" << SUNDAES_COST << endl;
foutt << "Number of Cones:" << totalICC << "@ $" << CONES_COST << endl;
foutt << "Number of Milk Shakes:" << totalMS << "@ $" << SHAKES_COST << endl << endl;
foutt << "Subtotal:" << "$ " << subTotal << endl;
foutt << "Tax:" << "$ " << totalTax << endl;
foutt << "Total:" << "$ " << totalCost << endl << endl;
foutt << "***********************************";
foutt.close ();
}
void WriteToInvintory (int numSundaes, int numCones, int numShakes)
{
const int OZ_TO_QT = 32;
const int OZ_TO_LB = 16;
const int IC_SUNDAES = 8;
const int IC_CONES = 6;
const int IC_SHAKES = 10;
const int NUTS_SUNDAES = 1;
const int SAUCE_SUNDAES = 2;
const int SAUCE_SHAKES = 1;
int amtIceCream = 0;
int amtNuts = 0;
int amtSauce = 0;
int amtCones = 0;
int qtIceCream = 0;
int lbNuts = 0;
int qtSauce = 0;
//Calculate the amount of ice cream
amtIceCream = IC_SUNDAES * numSundaes;
+ IC_CONES *numCones;
+ IC_SHAKES * numShakes;
//Calculate the amount of nuts
amtNuts = NUTS_SUNDAES * numSundaes;
//Calculate the amount of sauce
amtSauce = SAUCE_SUNDAES * numSundaes;
+ SAUCE_SHAKES * numShakes;
//Calculate the amount of cones
amtCones = numCones;
//Convert to units
qtIceCream = int (ceil(amtIceCream / OZ_TO_QT));
lbNuts = int (ceil(amtNuts / OZ_TO_LB));
qtSauce = int (ceil(amtSauce / OZ_TO_QT));
ofstream fout;
fout.open ("inventory.rpt");
fout << "Inventory Order report:" << endl << endl;
fout << "Ice Cream:" << qtIceCream << " quarts" << endl;
fout << "Nuts:" << lbNuts << " pounds" << endl;
fout << "Sauce:" << qtSauce << " quarts" << endl;
fout << "Cones:" << amtCones << endl << endl;
fout << "**************************************";
fout.close ();
}
int OrderItems()
{
int numItem;
cin >> numItem;
return (numItem);
}
int main ()
{
int iCS; //Ice cream sundaes
int iCC; //ice cream cones
int mS; //milk shakes
int caseInput; //case selection
int totalICS; //total ice cream sundaes
int totalICC; //total ice cream cones
int totalMS; //total milk shakes
string check; //yes or no choice of user
void ResetValues(int &iCS, int &iCC, int &mS, int &totalICS, int &totalICC, int &totalMS);
do {
cout << " Menu :" << endl;
cout << " 1 - Clear Order data" << endl;
cout << " 2 - Order Ice Cream Sundaes" << endl;
cout << " 3 - Order Ice Cream Cones" << endl;
cout << " 4 - Order Mile Shakes" << endl;
cout << " 5 - Generate Receipt for order" << endl;
cout << " 6 - Exit program (generate invintory data)" << endl;
cout << " 7 - Help" << endl << endl;
cout << "Select ===> ";
cin >> caseInput;
switch (caseInput){
case 1:
cout << "Are you sure you would like to start the order over? (Y/N) : ";
cin.get (check);
cin.ignore(256, '\n');
if (check == "Y") {
void ResetValues(int &iCS, int &iCC, int &mS, int &totalICS, int &totalICC, int &totalMS);
cout << "You have cleared the data to start a new order..." << endl << endl;
}
else {
cout << "You have not cleared the data. Continue order..." << endl << endl;
}
break;
case 2:
//function to store # ice cream sundaes
cout << "Number of Ice Cream Sundaes you would like: ";
totalICS = totalICS + OrderItems();
break;
case 3:
//function to store # ice cream cones
cout << "Number of Ice Cream Cones you would like: ";
totalICC = totalICC + OrderItems();
break;
case 4:
//function to store # of milk shakes
cout << "Number of Milk Shakes you would like: ";
totalMS = totalMS + OrderItems();
break;
case 5:
CashOut(totalICS, totalICC, totalMS);
void ResetValues(int &iCS, int &iCC, int &mS, int &totalICS, int &totalICC, int &totalMS);
break;
case 6:
{
void WriteToInventory(int totalICS,int totalICC,int totalMS);
exit (0);
//break;
}
case 7:
//show help
//MenuHelp();
break;
}
} while (caseInput != 6);
return 0;
}
|