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
|
//David Wood
//December 4,2018
//Automated Diner menu
// This program will automate the ordering and billing of a diner. It will print the menu onto the screen
// and have the user chose how many times they want to order, then it will total the price and print a receipt
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <stdlib.h>
#include "Structure.h"
#include "CustomerInformation.h"
using namespace std;
void Introduction(); // Prototype for Introduction
void printCheck(CustomerInfo); // Prototype for PrintCheck
void showMenu(); // Prototype for showMenu
int getData(); // Prototype for getData;
int main() {
int CustomerNumber; // Gives each customer a number 0-99
char Y_N = 'y';
char Continue;
getData(); // Function from another classmate. gets menu information from a file and puts information into arra
for (CustomerNumber = 0; CustomerNumber < 100; CustomerNumber++) {
Introduction(); // calls the introduction
cout << endl << endl << endl;
cout << "Your order will be order number: " << CustomerNumber << endl;
cout << endl;
Customer[CustomerNumber].counter = 0;
do {
int order;
showMenu(); // User Function That prints out meneu information
cout << "What would you like, You will be able to order more than once ( Input one order at a time) " << endl; // prompts user to input their order
cin >> order;
cout << "You chose " << MenuList[order].menuItem // prints out what the user chose
<< "......" << MenuList[order].menuPrice << endl;
Customer[CustomerNumber].orderItems[Customer[CustomerNumber].counter] = order;
Customer[CustomerNumber].counter++; // incriments counter
cout << " Would you like to order again (enter 'y,Y' or 'n,N )" << endl; // prompts user to input if they want to order again
cin >> Y_N;
} while (Y_N == 'y' || Y_N == 'Y'); // while the customer wants to order
//cout <<"This is the counter for customer" << Customer[CustomerNumber].counter << endl << endl; // Debugging
system("CLS"); // clears the screen
printCheck(Customer[CustomerNumber]);// Prints the check
//Owner can end program if no other customers are in diner
cout << endl << endl << endl; // clears a few lines
cout << "New Customer Please input 'C'" << endl
<< "Owner: Enter O" << endl;
cin >> Continue; //prompts user to input c for customer or o for owner to continue or end code
if (Continue == 'c' || Continue == 'C') { // if user enters c clear the screen and continue to loop
system("CLS");
}
else if (Continue == 'o' || Continue == 'O') { // if user enters o end code
break;
}
}
system("pause");
return 0;
}
//David Wood
//December 4,2018
//Introduction
//The intro to the code
void Introduction() {
cout << "Hello, Welcome to the diner. This program will automate the ordering and billing process" << endl
<< "The menu will be printed onto the screen for you to pick your order, you will be able to order" << endl
<< "as much as you like, the code will then print a receipt for you to pay with." << endl;
}
//David Wood
//December 4,2018
//Printcheck
//Function to print the final check for each customer
void printCheck(CustomerInfo ThisOrder) {
double receipt_total = 0; // receipt total
const double TAX_VALUE = .08125; // tax constant
double tax; // Value for tax to be multiplied to receipt_total
double Total; // Total for order w/ tax
cout << "Here is your check, Please come again!" << endl << endl;
for (int i = 0; i < ThisOrder.counter; i++) { // Prints out the order for customer
cout << MenuList[ThisOrder.orderItems[i]].menuItem << setfill('.') << setw(10)
<< MenuList[ThisOrder.orderItems[i]].menuPrice << endl;
}
for (int i = 0; i < ThisOrder.counter; i++) { //tallys up the total price and prints
receipt_total += MenuList[ThisOrder.orderItems[i]].menuPrice;
}
cout <<"Total w/o Tax" <<setfill('*')<< setw(10) <<"$" << receipt_total << endl;
tax = receipt_total * TAX_VALUE;
Total = tax + receipt_total;
cout << "Total w/ Tax" << setfill('*') << setw(10) << "$" << Total << endl;;
}
//int getData()
//
//}
// Menu
// David Santiago
// November 30, 2018
// This function will present a menu to the user and will explain to them, how to select a food item to order.
void showMenu() {
cout << setfill(' ') << setw(20) << "DCC Diner"<< endl;
// loop to output the item and price of the arrays
for (int i = 0; i < 2; i++)
{
// outputing the menu item and menu price
cout << i <<": " << MenuList[i].menuItem << "................." << MenuList[i].menuPrice << endl;
}
// outputting an instruction on how to select the food itme the user wants
cout << "In order to order food, please enter in a number between 0 and 8. The numbers correspond with the food items going down, the first food item is 0 and so on: " << endl;
}
|