Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include<iomanip>
- using namespace std;
- const int listSize = 8;
- const double theTax = .05;
- struct menuItemType
- {
- string menuItem;
- double menuPrice;
- };
- void getData(ifstream& inFile, menuItemType mlist[], int menuSize);
- void showMenu(menuItemType mlist[], int menuSize);
- void makeSlection(menuItemType mList[], int listSize, int cList[][2], int& cListLength);
- void printCheck(ofstream& outFile, menuItemType mlist[], int menuSize, int choices[][2], int choiceSize);
- int main()
- {
- menuItemType menu[listSize];
- int choiceList[listSize][2];
- int choiceListLength;
- ifstream inFile;
- ofstream outFile;
- inFile.open("input.txt", ios::in);
- outFile.open("output.txt", ios::in);
- if((!inFile) || (!outFile))
- {
- cout<<" The text file does not exist."<<endl;
- }
- else
- {
- getData(inFile, menu, listSize);
- showMenu(menu, listSize);
- makeSlection(menu, listSize, choiceList, choiceListLength);
- printCheck(outFile, menu, listSize, choiceList, choiceListLength);
- inFile.close();
- outFile.close();
- }
- system("pause");
- return 0;
- }
- void getData(ifstream& inFile, menuItemType menu[], int listSize)
- {
- for (int z = 0; z<listSize; z++)
- {
- getline(inFile, menu[z].menuItem, '$');
- inFile >> menu[z].menuPrice;
- inFile.ignore(1000, '\n');
- }
- }
- void showMenu(menuItemType mlist[], int listSize)
- {
- for (int z = 0; z<listSize; z++)
- {
- cout<<(z+1)<<":"<<left<<setw(5)<<mlist[z].menuItem<<setw(10)<<mlist[z].menuPrice<<endl;
- }
- }
- void makeSlection(menuItemType mList[], int listSize, int cList[][2], int& cListLength)
- {
- int selectioNo = 0;
- int itemNo;
- int nooforder;
- char respond;
- for (int i = 0; i<listSize; i++)
- {
- cList[i][1] = 0;
- }
- cout << " You can make up to " << listSize //8
- << " different selections:" << endl;
- cout << "Do you want to make selection Y/y (yes),N/n (N0):" << endl;
- cin >> respond;
- cout << endl;
- while ((respond == 'Y' || respond == 'y') && (cListLength<listSize))
- {
- cout << "enter Item number:" << endl;
- cin >> itemNo;
- cout << endl;
- cout << "How many Orders:" << endl;
- cin >> nooforder;
- cList[cListLength][0] = itemNo - 1;
- cList[cListLength++][1] += nooforder;
- cout << "selection Item (Y/y (yes) , N/y (No):" << endl;
- cout << respond;
- cout << endl;
- }
- }
- void printCheck(ofstream& outFile, menuItemType mlist[], int menuSize, int choices[][2], int choiceSize)
- {
- double price = 0.0, tax = 0.0, total = 0.0;
- outFile << "\nWelcome to Some Name Restaurant" << endl;
- outFile << "Orders and price:" << endl;
- for (int z = 0; z < listSize; z++)
- {
- outFile << mlist[z].menuItem << "\t" << mlist[z].menuPrice << endl;
- }
- tax = 0.05 * price;
- total = tax + price;
- outFile << setprecision(2) << fixed;
- outFile << "\nTax= $" << tax << endl;
- outFile << "Amount Due= $" << total << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement