Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<conio.h>
- #include<iomanip>
- using namespace std;
- int choice, choice1;
- int n, dr, d;
- int i;
- int order;
- char ans = 'y';
- char reply1 = 'y';
- string meal[15], drinks[15], dessert[15];
- string code[15] = { "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", }, test, search,edit,editcatcher,answer;
- string code2[15] = { "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", }, test2, search2;
- string code3[15] = { "301", "302", "303", "304", "305", "306", "307", "308", "309", "310", "311", "312", "313", "314", "315", }, test3, search3;
- double price[15], price2[15], price3[15];
- double total = 0;
- double qty1, qty2, qty3;
- int x = 1;
- double pr1 = 0, pr2 = 0, pr3 = 0;
- double TOTAL = 0;
- double additional = 0;
- char reply = 'y';
- //funtions
- int displaycase1()
- {
- cout << "\n\n\t\t\t ADD NEW items" << endl;
- cout << "\n\nNote: Can aacept only 15 different items" << endl;
- cout << "\nEnter number of Meal[1-15]:";
- cin >> n;
- for (i = 0; i < n; i++){//case1loop
- cout << "\nItem code:" << code[i];
- cout << "\nMeal name:";
- cin >> (meal[i]);
- cout << "Price:";
- cin >> (price[i]);
- }//case1loop
- cout << "\nEnter number of Drinks[1-15]:";
- cin >> dr;
- for (i = 0; i < dr; i++){
- cout << "\nItem code:" << code2[i];
- cout << "\nDrink name:";
- cin >> (drinks[i]);
- cout << "Price:";
- cin >> (price2[i]);
- }//1loop2
- cout << "\nEnter number of Desserts[1-15]:";
- cin >> d;
- for (i = 0; i < d; i++){
- cout << "\nItem code:" << code3[i];
- cout << "\nDessert name:";
- cin >> (dessert[i]);
- cout << "Price:";
- cin >> (price3[i]);
- }//1loopdessert
- system("cls");
- return 0;
- }
- int displaycase2()
- {
- system("cls");
- cout << "\n------------------------------MENU-------------------------" << endl;
- cout << "\n\n==============================Meals===============================" << endl;
- cout << "_______________________________________________________________" << endl;
- cout << "Code\t\t\tMeal\t\t\t Price\n__________________________________________________________________" << endl;
- for (i = 0; i < n; i++){
- cout << setw(20) << "\n" << code[i];
- cout << " ";
- cout << setw(25) << meal[i];
- cout << " ";
- cout << setw(25) << price[i];
- cout << " ";
- cout << endl;
- }//meal
- cout << "\n\n==============================Drinks==============================" << endl;
- cout << "\n__________________________________________________________________" << endl;
- cout << "Code\t\t\tDrinks\t\t\t Price\n__________________________________________________________________" << endl;
- for (i = 0; i < dr; i++){
- cout << setw(20) << "\n" << code2[i];
- cout << " ";
- cout << setw(25) << drinks[i];
- cout << " ";
- cout << setw(25) << price2[i];
- cout << " ";
- cout << endl;
- }//drinks
- cout << "\n\n==============================Dessert=============================" << endl;
- cout << "\n__________________________________________________________________" << endl;
- cout << "Code\t\t\tDessert\t\t\t Price\n__________________________________________________________________" << endl;
- for (i = 0; i < d; i++){
- cout << setw(20) << "\n" << code3[i];
- cout << " ";
- cout << setw(25) << dessert[i];
- cout << " ";
- cout << setw(25) << price3[i];
- cout << " ";
- cout << endl;
- }
- return 0;
- }
- int displaycase3()
- {
- system("cls");
- cout << "\n\n\t\t\t Edit Items\n";
- cout << "Which order do you want to edit?\n";
- cout << "[1]MEAL\n[2]DRINKS\n[3]DESSERT";
- cout << "\nChoose:";
- cin >> order;
- if (order == 1)
- {
- cout << "\n\n==============================Meals===============================" << endl;
- cout << "______________________________________________________________" << endl;
- cout << "Code\t\t Meal's\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < n; i++){
- cout << setw(20) << "\n" << code[i];
- cout << " ";
- cout << setw(20) << meal[i];
- cout << " ";
- cout << setw(30) << price[i];
- cout << " ";
- cout << endl;
- }//meal
- cout << "\nWhich set of list do you want to edit?\nPlease enter the code: " << endl;
- cin >> edit;
- for (i = 0; i < 15; i++)
- {
- if (edit == code[i])
- {
- cout << "Enter new code:";
- cin >> code[i];
- cout << "Enter new name:";
- cin >> meal[i];
- cout << "New Price:";
- cin >> price[i];
- i = 15;
- }
- else if (edit != code[i])
- {
- for (int j = 0; j < 15; j++)
- {
- if (edit == code[j])
- {
- edit = code[j];
- }
- }
- if (edit == code[i])
- {
- cout << "Enter new code:";
- cin >> code[i];
- cout << "Enter new name:";
- cin >> meal[i];
- cout << "New Price:";
- cin >> price[i];
- i = 15;
- }
- }
- else
- {
- cout << "\nInvalid Input\n";
- }
- }
- }//if
- else if (order == 2)
- {
- cout << "\n\n==============================Drinks==============================" << endl;
- cout << "______________________________________________________________" << endl;
- cout << "Code\t\t Drinks\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < dr; i++){
- cout << setw(20) << "\n" << code2[i];
- cout << " ";
- cout << setw(20) << drinks[i];
- cout << " ";
- cout << setw(30) << price2[i];
- cout << " ";
- cout << endl;
- }//drinks
- cout << "Which set of list do you want to edit?\nPlease enter the code: " << endl;
- cin >> edit;
- for (i = 0; i < 15; i++)
- {
- if (edit == code2[i])
- {
- cout << "Enter new code:";
- cin >> code2[i];
- cout << "Enter new name:";
- cin >> drinks[i];
- cout << "New Price:";
- cin >> price2[i];
- i = 15;
- edit = editcatcher;
- }
- else
- {
- cout << "\n\nInvalid Code input.";
- i = 15;
- }
- }
- }
- else if (order == 3)
- {
- cout << "\n\n==============================Dessert==============================" << endl;
- cout << "\n__________________________________________________________________" << endl;
- cout << "Code\t\t Dessert\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < n; i++){
- cout << setw(20) << "\n" << code3[i];
- cout << " ";
- cout << setw(20) << dessert[i];
- cout << " ";
- cout << setw(30) << price3[i];
- cout << " ";
- cout << endl;
- }
- cout << "Which set of list do you want to edit?\nPlease enter the code: " << endl;
- cin >> edit;
- for (i = 0; i < 15; i++)
- {
- if (edit == code3[i])
- {
- cout << "Enter new code:";
- cin >> code3[i];
- cout << "Enter new name:";
- cin >> dessert[i];
- cout << "New Price:";
- cin >> price3[i];
- cout << "Successfully edited!" << endl;
- i = 15;
- }
- else
- {
- cout << "\n\nInvalid Code input.";
- i = 15;
- }
- }
- }
- else
- {
- cout << "Invalid Input!" << endl;
- }
- return 0;
- }
- int displaycase4()
- {
- system("cls");
- cout << "\n\n\t\t\t PURCHASE\n" << endl;
- for (choice1 = 0; choice1 <6; choice1++){
- cout << "\n[1]MEAL\n[2]DRINKS\n[3]DESSERT\n[4]Finish Ordering\n[5]EXIT" << endl;
- cout << "Choose:";
- cin >> choice1;
- if (choice1 == 1){
- cout << "------------------------------MENU-------------------------" << endl;
- cout << "\n==============================Meals===============================" << endl;
- cout << "______________________________________________________________" << endl;
- cout << "Code\t\t Meal's\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < n; i++){
- cout << setw(20) << "\n" << code[i];
- cout << " ";
- cout << setw(20) << meal[i];
- cout << " ";
- cout << setw(30) << price[i];
- cout << " ";
- cout << endl;
- }//meal
- cout << "\nENTER CODE TO PURCHASE" << endl;
- cout << "What is your meal?" << endl;
- cin >> test;
- for (int w = 0; w < 15; w++)
- {
- if (test == code[w])
- {
- cout << "How many? " << endl;
- cin >> qty1;
- pr1 = qty1*price[w];
- w = 15;
- }
- }
- cout << "\nAMOUNT TO PAY:";
- cout << pr1 << endl;
- }
- else if (choice1 == 2){
- cout << "------------------------------MENU-------------------------" << endl;
- cout << "\n\n==============================Drinks==============================" << endl;
- cout << "______________________________________________________________" << endl;
- cout << "Code\t\t Drinks\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < dr; i++){
- cout << setw(20) << "\n" << code2[i];
- cout << " ";
- cout << setw(20) << drinks[i];
- cout << " ";
- cout << setw(30) << price2[i];
- cout << " ";
- cout << endl;
- }
- cout << "What is your drinks?" << endl;
- cin >> test2;
- for (int z = 0; z < 15; z++)
- {
- if (test2 == code2[z])
- {
- cout << "How many? " << endl;
- cin >> qty2;
- pr2 = qty2*price2[z];
- z = 15;
- }
- }
- cout << "\nAMOUNT TO PAY:";
- cout << pr2 << endl;
- }
- else if (choice1 == 3){
- cout << "\n\n==============================Dessert==============================" << endl;
- cout << "\n__________________________________________________________________" << endl;
- cout << "Code\t\t Dessert\t\t\t\tPrice\n__________________________________________________________________" << endl;
- for (i = 0; i < d; i++){
- cout << setw(20) << "\n" << code3[i];
- cout << " ";
- cout << setw(20) << dessert[i];
- cout << " ";
- cout << setw(30) << price3[i];
- cout << " ";
- cout << endl;
- }
- cout << "What is your dessert? " << endl;
- cin >> test3;
- for (int y = 0; y < 15; y++)
- {
- if (test3 == code3[y])
- {
- cout << "How many? ";
- cin >> qty3;
- pr3 = qty3 * price3[y];
- y = 15;
- }
- }
- cout << "\nAMOUNT TO PAY:";
- cout << pr3 << endl;
- }
- else if (choice1 == 4){
- total = pr1 + pr2 + pr3;
- cout << "\n\n\n\nTOTAL PRICE TO PURCHASE: " << total << endl;
- cout << "\n\nAnother transaction?[Y/N]:";
- cin >> reply1;
- if (reply1 == 'y' || reply1 == 'Y')
- {
- pr1 = 0;
- pr2 = 0;
- pr3 = 0;
- cout << "\n\n\nANOTHER TRANSACTION" << endl;
- }
- else {
- system("cls");
- cout << "\n\n\t\t\t\tTHANK YOU " << endl;
- cout << "\n\n\n\nPRESS[5] TO EXIT\n\n" << endl;
- }//elsesaloob
- }
- else
- {
- system("cls");
- cout << "Thank you!" << endl;
- }
- }//for loop
- return 0;
- }
- int displaycase5()
- {
- system("cls");
- cout << "\n\n\t\t\t Search Order\n";
- cout << "Which order do you want to search?\n";
- cout << "[1]MEAL\n[2]DRINKS\n[3]DESSERT";
- cout << "\nChoose:";
- cin >> order;
- switch (order){//nested switch
- case 1:
- system("cls");
- cout << "MEAL" << endl;
- cout << "Enter code : ";
- cin >> search;
- for (int i = 0; i < 15; i++)
- {
- if (search == code[i])
- {
- cout << "MEAL: " << meal[i] << "\n" << "PRICE: " << price[i] << "\n";
- i = 15;
- }
- }//loop case 1
- break;
- case 2:
- system("cls");
- cout << "Drinks" << endl;
- cout << "Enter code : ";
- cin >> search2;
- for (int i = 0; i < 15; i++)
- {
- if (search2 == code2[i])
- {
- cout << "DRINKS: " << drinks[i] << "\n" << "PRICE: " << price2[i] << "\n";
- i = 15;
- }
- }//loop case 2
- break;
- case 3:
- system("cls");
- cout << "Dessert" << endl;
- cout << "Enter code : ";
- cin >> search3;
- for (int i = 0; i < 15; i++)
- {
- if (search3 == code3[i])
- {
- cout << "DESSERT: " << dessert[i] << "\n" << "PRICE: " << price3[i] << "\n";
- i = 15;
- }
- }//loop case 3
- break;
- }//end of switch inside case 5
- return 0;
- }
- //end of function
- int main()
- {//main
- cout << "%%%%%%%%%%%%%%%%%%%%%%%" << endl;
- cout << "WELCOME TO JACDO" << endl;
- cout << "%%%%%%%%%%%%%%%%%%%%%%%" << endl;
- while (reply == 'y' || reply == 'Y'){//while
- cout << "--------------------" << endl;
- cout << "[1]Add Meal\n[2]Display your meal\n[3]Update\n[4]Purchase\n[5]Search\n";
- cout << "--------------------" << endl;
- cout << "Choose: ";
- cin >> choice;
- switch (choice){
- case 1:
- displaycase1();
- break;
- case 2:
- displaycase2();
- break;
- case 3:
- displaycase3();
- break;
- case 4:
- displaycase4();
- break;
- case 5:
- displaycase5();
- break;
- default:
- {
- system("cls");
- cout << "INVALID! Please try again!" << endl;
- }
- }//switch
- }//while
- cout << "Do you want another transaction[y/n]?";
- cin >> reply;
- if (reply == 'n' || reply == 'N'){
- cout << "Thank you";
- }
- _getch();
- }//main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement