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
|
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
class menuItemType
{
public:
string itemName;
double itemCost;
private:
void getData(menuItemType item[], ofstream& outData);
void showMenu(menuItemType item[], ofstream& outData);
void printCheck (double& total, double& tax, double& totalF, ofstream& outData);
};
int main()
{
ofstream outData;
outData.open("OutMenu.txt");
cout<< " Welcome !:) " << endl;
cout<< "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout<< " *To select an Item from the list below, " << endl;
cout<< "just indicate the Item number for the item \n\n" << endl;
outData << " Welcome! :) " << endl;
outData << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
outData << " *To select an Item from the list below, " << endl;
outData<< "just indicate the Item number for the item \n\n" << endl;
menuItemType menu [8];
/* getData(menu, outData);
showMenu(menu, outData);*/
system("pause");
return 0;
}
void menuItemType :: getData(menuItemType item[], ofstream& outData)
{
int i=0;
ifstream inData;
inData.open("InMenu.txt");
cout << fixed << setprecision(2);
outData << fixed << setprecision(2);
while(!inData.eof())
{
inData >> item[i].itemName >> item[i].itemCost;
++i;
}
}
void menuItemType :: showMenu(menuItemType item[],ofstream& outData)
{
int choice = 0;
double total = 0.0, totalF = 0.0, tax = 0.0;
char exit = 'y';
int j = 1, z = 1, i = 1;
//the Menu
for (int i=0; i<8; i++)
{
cout << j << ". " << setw(18) << left << item[i].itemName << "$" << setw(10) << item[i].itemCost << endl;
outData << j << ". " << setw(18) << left << item[i].itemName << "$" << setw(10) << item[i].itemCost << endl;
j++;
}
cout << endl;
while(exit == 'y' || exit == 'Y')
{
cout << "Please Enter your Selection or 0 to Exit : ";
cin >> choice;
if(cin.fail()) {
cout << "~~~~~~~~~Invalid selection~~~~~~~~~" << endl;
cin.clear();
cin.ignore(1000,'\n');
}
else if (choice==0) {break; }
else
{
choice--;
total += (item[choice].itemCost);
tax = (total * .05);
totalF = total + tax;
cout << endl;
outData << endl;
}
cout << endl;
outData << endl;
cout << item[choice].itemName << " " << item[choice].itemCost << endl;
cout << "======================================================" << endl;
cout << "Do you want to continue (Y/N): ";
outData << item[choice].itemName << " " << item[choice].itemCost << endl;
outData << "======================================================" << endl;
outData << "Do you want to continue (Y/N): ";
cin >> exit;
}
printCheck(total, tax, totalF, outData);
}
void menuItemType :: printCheck(double& total, double& tax, double& totalF, ofstream& outData)
{
cout << "\n\nThanks for Dinning With Us!" << endl;
cout << "<><><><><><><><><><><><><><>\n" << endl;
cout << "Customer Receipt " << endl;
cout << "SubTotal: $" << total <<endl;
cout << "Tax: $" << tax << endl;
cout << " -----" << endl;
cout << "Total: $" << totalF << endl;
cout << "Please Come Again!" << endl;
outData << "\n\nThanks for Dinning With Us!" << endl;
outData << "<><><><><><><><><><><><><><>\n" << endl;
outData << "Customer Receipt " << endl;
outData << "SubTotal: $" << total <<endl;
outData << "Tax: $" << tax << endl;
outData << " -----" << endl;
outData << "Total: $" << totalF << endl;
outData << "Please Come Again!" << endl;
}
|