Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************
- * AUTHOR : Matthew Fernandes
- * Assignment 11 : Breakfast Billing System
- * CLASS : CS02
- * SECTION : MW: 7a - 8:30p, F: 7a - 11p
- * Due Date : 12/5/16
- *****************************************************************************/
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- #include <iomanip>
- #include <ctype.h>
- using namespace std;
- /*****************************************************************************
- *
- * Assignement 11 - Breakfast Billing System
- *____________________________________________________________________________
- * Intro
- *
- *____________________________________________________________________________
- * INPUT:
- *
- * OUTPUT:
- *
- *****************************************************************************/
- void Header();
- void getData();
- void showMenu();
- void printCheck(vector <string>, vector <int>);
- struct menuItemType
- {
- string menuItem;
- double menuPrice;
- };
- /*****************************************************************************
- * Header
- * This function will output the class header when called in main.
- * - returns nothing
- *****************************************************************************/
- void Header()
- {
- //OUTPUT - class heading on the screen
- string Header(80, '*');
- cout << Header << endl;
- cout << " Programmed by : Matthew Fernandes\n";
- cout << " Student ID : 10019167\n";
- cout << " CS02 : MW: 7a - 8:30p, F: 7a - 11p\n";
- cout << " Assignment 11 : Breakfast Billing System\n";
- cout << Header << endl;
- }
- menuItemType data[8];
- void getData()
- {
- ifstream myFile;
- myFile.open("menu.txt");
- //For looped used to put the contents of the file into the array.
- for(int i = 0; i < 8; i++)
- {
- getline(myFile, data[i].menuItem);
- }
- myFile.close();
- }
- void showMenu()
- {
- getData();
- for(int i = 0; i < 8; i++)
- {
- cout << data[i].menuItem << endl;
- }
- }
- void printCheck(vector <string> items, vector <int> numbers)
- {
- double a = 0.0,b = 0.0,c = 0.0,d = 0.0,e = 0.0,f = 0.0,
- g = 0.0,h = 0.0,total = 0.0, tax = 0.0, finished = 0.0;
- int num[8] = {0,0,0,0,0,0,0,0};
- double price[8] = {0,0,0,0,0,0,0,0};
- for(int i = 0; i <numbers.size(); i++)
- {
- num[i] = numbers.at(i);
- }
- for(int i = 0; i < items.size(); i ++)
- {
- if("Plain Egg" == items.at(i) || "plain egg" == items.at(i))
- {
- price[i] = (price[i] + 1.45)*num[i];
- a = price[i];
- }
- if("Muffin" == items.at(i) || "muffin" == items.at(i))
- {
- price[i] = (price[i] + .99)*num[i];
- b = price[i];
- }
- if("Fruit Basket" == items.at(i) || "fruit basket" == items.at(i))
- {
- price[i] = (price[i] + 2.49)*num[i];
- c = price[i];
- }
- if("Coffee" == items.at(i) || "coffee" == items.at(i))
- {
- price[i] = (price[i] + .5)*num[i];
- d = price[i];
- }
- if("Bacon and Egg" == items.at(i) || "bacon and egg" == items.at(i))
- {
- price[i] = (price[i] + 2.45)*num[i];
- e = price[i];
- }
- if("French Toast" == items.at(i) || "french toast" == items.at(i))
- {
- price[i] = (price[i] + 1.99)*num[i];
- f = price[i];
- }
- if("Cereal" == items.at(i) || "cereal" == items.at(i))
- {
- price[i] = (price[i] + .69)*num[i];
- g = price[i];
- }
- if("Tea" == items.at(i) || "tea" == items.at(i))
- {
- price[i] = (price[i] + .75)*num[i];
- h = price[i];
- }
- }
- total = a + b + c + d + e + f + g + h;
- tax = total*.05;
- finished = tax+total;
- //int spaces;
- cout << "Welcome to Johnny's Restaurant" << endl;
- cout << endl;
- for(int i = 0; i < numbers.size(); i++)
- {
- //spaces = 35 - sizeof(items)/sizeof(items[i]);
- cout << fixed << setprecision(2)<< numbers.at(i) << " "
- << left << setw(34) << items.at(i)<< "$" << price[i] << endl;
- }
- cout << "Tax $" << tax << endl;
- cout << "-----------------------------------------" << endl;
- cout << "Amount Due $" << finished << endl;
- }
- int main()
- {
- Header();
- cout << "Welcome to Johnny's Restaurant" << endl;
- cout << endl;
- showMenu();
- string rawInput;
- int num;
- vector <int> numbers;
- vector<string> items;
- cout << endl;
- cout << "Choose your items from the menu followed by [ENTER]." << endl;
- cout << "Enter 'done' to finish your order: " << endl;
- while(rawInput != "done")
- {
- getline(cin,rawInput);
- if(rawInput == "Plain Egg" || rawInput == "Bacon and Egg"
- || rawInput == "Muffin" || rawInput == "French Toast"
- || rawInput == "Fruit Basket" || rawInput == "Cereal"
- || rawInput == "Coffee" || rawInput == "Tea"
- || rawInput == "plain egg" || rawInput == "bacon and egg"
- || rawInput == "muffin" || rawInput == "french toast"
- || rawInput == "fruit basket" || rawInput == "cereal"
- || rawInput == "coffee" || rawInput == "tea" || rawInput == "done")
- {
- if(rawInput == "done")
- break;
- else
- items.push_back(rawInput);
- }
- else
- {
- cout << "Sorry that's not a valid input, please enter a valid choice: ";
- cout << endl;
- }
- }
- cout << endl;
- for(int i = 0; i < items.size(); i++)
- {
- cout << "How many " << items.at(i) << "s would you like? ";
- cin >> num;
- numbers.push_back(num);
- }
- cout << endl;
- printCheck(items, numbers);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement