Advertisement
Guest User

Untitled

a guest
May 26th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<conio.h>
  4. #include<iomanip>
  5. using namespace std;
  6.  
  7. int choice, choice1;
  8. int n, dr, d;
  9. int i;
  10. int order;
  11. char ans = 'y';
  12. char reply1 = 'y';
  13. string meal[15], drinks[15], dessert[15];
  14. string code[15] = { "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", }, test, search,edit,editcatcher,answer;
  15. string code2[15] = { "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", }, test2, search2;
  16. string code3[15] = { "301", "302", "303", "304", "305", "306", "307", "308", "309", "310", "311", "312", "313", "314", "315", }, test3, search3;
  17. double price[15], price2[15], price3[15];
  18.  
  19. double total = 0;
  20. double qty1, qty2, qty3;
  21.  
  22. int x = 1;
  23.  
  24. double pr1 = 0, pr2 = 0, pr3 = 0;
  25. double TOTAL = 0;
  26. double additional = 0;
  27.  
  28. char reply = 'y';
  29.  
  30.  
  31. //funtions
  32. int displaycase1()
  33. {
  34. cout << "\n\n\t\t\t ADD NEW items" << endl;
  35. cout << "\n\nNote: Can aacept only 15 different items" << endl;
  36. cout << "\nEnter number of Meal[1-15]:";
  37. cin >> n;
  38. for (i = 0; i < n; i++){//case1loop
  39. cout << "\nItem code:" << code[i];
  40. cout << "\nMeal name:";
  41. cin >> (meal[i]);
  42. cout << "Price:";
  43. cin >> (price[i]);
  44. }//case1loop
  45. cout << "\nEnter number of Drinks[1-15]:";
  46. cin >> dr;
  47. for (i = 0; i < dr; i++){
  48. cout << "\nItem code:" << code2[i];
  49. cout << "\nDrink name:";
  50. cin >> (drinks[i]);
  51. cout << "Price:";
  52. cin >> (price2[i]);
  53.  
  54. }//1loop2
  55.  
  56. cout << "\nEnter number of Desserts[1-15]:";
  57. cin >> d;
  58. for (i = 0; i < d; i++){
  59. cout << "\nItem code:" << code3[i];
  60. cout << "\nDessert name:";
  61. cin >> (dessert[i]);
  62. cout << "Price:";
  63. cin >> (price3[i]);
  64.  
  65. }//1loopdessert
  66.  
  67. system("cls");
  68. return 0;
  69. }
  70. int displaycase2()
  71.  
  72. {
  73. system("cls");
  74. cout << "\n------------------------------MENU-------------------------" << endl;
  75. cout << "\n\n==============================Meals===============================" << endl;
  76. cout << "_______________________________________________________________" << endl;
  77. cout << "Code\t\t\tMeal\t\t\t Price\n__________________________________________________________________" << endl;
  78. for (i = 0; i < n; i++){
  79. cout << setw(20) << "\n" << code[i];
  80. cout << " ";
  81. cout << setw(25) << meal[i];
  82. cout << " ";
  83. cout << setw(25) << price[i];
  84. cout << " ";
  85. cout << endl;
  86. }//meal
  87.  
  88. cout << "\n\n==============================Drinks==============================" << endl;
  89. cout << "\n__________________________________________________________________" << endl;
  90. cout << "Code\t\t\tDrinks\t\t\t Price\n__________________________________________________________________" << endl;
  91. for (i = 0; i < dr; i++){
  92. cout << setw(20) << "\n" << code2[i];
  93. cout << " ";
  94. cout << setw(25) << drinks[i];
  95. cout << " ";
  96. cout << setw(25) << price2[i];
  97. cout << " ";
  98. cout << endl;
  99. }//drinks
  100.  
  101. cout << "\n\n==============================Dessert=============================" << endl;
  102. cout << "\n__________________________________________________________________" << endl;
  103. cout << "Code\t\t\tDessert\t\t\t Price\n__________________________________________________________________" << endl;
  104. for (i = 0; i < d; i++){
  105. cout << setw(20) << "\n" << code3[i];
  106. cout << " ";
  107. cout << setw(25) << dessert[i];
  108. cout << " ";
  109. cout << setw(25) << price3[i];
  110. cout << " ";
  111. cout << endl;
  112. }
  113. return 0;
  114. }
  115.  
  116. int displaycase3()
  117. {
  118. system("cls");
  119. cout << "\n\n\t\t\t Edit Items\n";
  120. cout << "Which order do you want to edit?\n";
  121. cout << "[1]MEAL\n[2]D­RINKS\n[3]DESSERT";
  122. cout << "\nChoose:";
  123. cin >> order;
  124. if (order == 1)
  125. {
  126. cout << "\n\n==============================Meals===============================" << endl;
  127. cout << "______________________________________________________________" << endl;
  128. cout << "Code\t\t Meal's\t\t\t\tPrice\n__________________________________________________________________" << endl;
  129. for (i = 0; i < n; i++){
  130. cout << setw(20) << "\n" << code[i];
  131. cout << " ";
  132. cout << setw(20) << meal[i];
  133. cout << " ";
  134. cout << setw(30) << price[i];
  135. cout << " ";
  136. cout << endl;
  137. }//meal
  138. cout << "\nWhich set of list do you want to edit?\nPlease enter the code: " << endl;
  139. cin >> edit;
  140. for (i = 0; i < 15; i++)
  141. {
  142.  
  143. if (edit == code[i])
  144. {
  145. cout << "Enter new code:";
  146. cin >> code[i];
  147. cout << "Enter new name:";
  148. cin >> meal[i];
  149. cout << "New Price:";
  150. cin >> price[i];
  151. i = 15;
  152. }
  153. else if (edit != code[i])
  154. {
  155. for (int j = 0; j < 15; j++)
  156. {
  157. if (edit == code[j])
  158. {
  159. edit = code[j];
  160. }
  161. }
  162. if (edit == code[i])
  163. {
  164. cout << "Enter new code:";
  165. cin >> code[i];
  166. cout << "Enter new name:";
  167. cin >> meal[i];
  168. cout << "New Price:";
  169. cin >> price[i];
  170. i = 15;
  171. }
  172. }
  173. else
  174. {
  175. cout << "\nInvalid Input\n";
  176. }
  177.  
  178. }
  179. }//if
  180.  
  181. else if (order == 2)
  182. {
  183. cout << "\n\n==============================Drinks==============================" << endl;
  184. cout << "______________________________________________________________" << endl;
  185. cout << "Code\t\t Drinks\t\t\t\tPrice\n__________________________________________________________________" << endl;
  186. for (i = 0; i < dr; i++){
  187. cout << setw(20) << "\n" << code2[i];
  188. cout << " ";
  189. cout << setw(20) << drinks[i];
  190. cout << " ";
  191. cout << setw(30) << price2[i];
  192. cout << " ";
  193. cout << endl;
  194. }//drinks
  195. cout << "Which set of list do you want to edit?\nPlease enter the code: " << endl;
  196. cin >> edit;
  197.  
  198. for (i = 0; i < 15; i++)
  199. {
  200. if (edit == code2[i])
  201. {
  202.  
  203. cout << "Enter new code:";
  204. cin >> code2[i];
  205. cout << "Enter new name:";
  206. cin >> drinks[i];
  207. cout << "New Price:";
  208. cin >> price2[i];
  209. i = 15;
  210. edit = editcatcher;
  211. }
  212. else
  213. {
  214. cout << "\n\nInvalid Code input.";
  215. i = 15;
  216. }
  217. }
  218. }
  219.  
  220. else if (order == 3)
  221. {
  222. cout << "\n\n==============================Dessert==============================" << endl;
  223. cout << "\n__________________________________________________________________" << endl;
  224. cout << "Code\t\t Dessert\t\t\t\tPrice\n__________________________________________________________________" << endl;
  225. for (i = 0; i < n; i++){
  226. cout << setw(20) << "\n" << code3[i];
  227. cout << " ";
  228. cout << setw(20) << dessert[i];
  229. cout << " ";
  230. cout << setw(30) << price3[i];
  231. cout << " ";
  232. cout << endl;
  233. }
  234. cout << "Which set of list do you want to edit?\nPlease enter the code: " << endl;
  235. cin >> edit;
  236.  
  237.  
  238. for (i = 0; i < 15; i++)
  239. {
  240. if (edit == code3[i])
  241. {
  242. cout << "Enter new code:";
  243. cin >> code3[i];
  244. cout << "Enter new name:";
  245. cin >> dessert[i];
  246. cout << "New Price:";
  247. cin >> price3[i];
  248. cout << "Successfully edited!" << endl;
  249. i = 15;
  250. }
  251. else
  252. {
  253. cout << "\n\nInvalid Code input.";
  254. i = 15;
  255. }
  256. }
  257. }
  258. else
  259. {
  260. cout << "Invalid Input!" << endl;
  261. }
  262. return 0;
  263. }
  264. int displaycase4()
  265. {
  266. system("cls");
  267. cout << "\n\n\t\t\t PURCHASE\n" << endl;
  268. for (choice1 = 0; choice1 <6; choice1++){
  269.  
  270. cout << "\n[1]MEAL\n[2]D­RINKS\n[3]DESSERT\n[4]Finish Ordering\n[5]EXIT" << endl;
  271. cout << "Choose:";
  272. cin >> choice1;
  273.  
  274. if (choice1 == 1){
  275. cout << "------------------------------MENU-------------------------" << endl;
  276. cout << "\n==============================Meals===============================" << endl;
  277. cout << "______________________________________________________________" << endl;
  278. cout << "Code\t\t Meal's\t\t\t\tPrice\n__________________________________________________________________" << endl;
  279. for (i = 0; i < n; i++){
  280. cout << setw(20) << "\n" << code[i];
  281. cout << " ";
  282. cout << setw(20) << meal[i];
  283. cout << " ";
  284. cout << setw(30) << price[i];
  285. cout << " ";
  286. cout << endl;
  287. }//meal
  288. cout << "\nENTER CODE TO PURCHASE" << endl;
  289. cout << "What is your meal?" << endl;
  290.  
  291. cin >> test;
  292. for (int w = 0; w < 15; w++)
  293. {
  294. if (test == code[w])
  295. {
  296.  
  297. cout << "How many? " << endl;
  298. cin >> qty1;
  299. pr1 = qty1*price[w];
  300.  
  301. w = 15;
  302. }
  303. }
  304. cout << "\nAMOUNT TO PAY:";
  305. cout << pr1 << endl;
  306. }
  307.  
  308. else if (choice1 == 2){
  309. cout << "------------------------------MENU-------------------------" << endl;
  310. cout << "\n\n==============================Drinks==============================" << endl;
  311. cout << "______________________________________________________________" << endl;
  312. cout << "Code\t\t Drinks\t\t\t\tPrice\n__________________________________________________________________" << endl;
  313. for (i = 0; i < dr; i++){
  314. cout << setw(20) << "\n" << code2[i];
  315. cout << " ";
  316. cout << setw(20) << drinks[i];
  317. cout << " ";
  318. cout << setw(30) << price2[i];
  319. cout << " ";
  320. cout << endl;
  321. }
  322. cout << "What is your drinks?" << endl;
  323. cin >> test2;
  324. for (int z = 0; z < 15; z++)
  325. {
  326. if (test2 == code2[z])
  327. {
  328. cout << "How many? " << endl;
  329. cin >> qty2;
  330. pr2 = qty2*price2[z];
  331.  
  332. z = 15;
  333. }
  334. }
  335. cout << "\nAMOUNT TO PAY:";
  336. cout << pr2 << endl;
  337. }
  338.  
  339. else if (choice1 == 3){
  340. cout << "\n\n==============================Dessert==============================" << endl;
  341. cout << "\n__________________________________________________________________" << endl;
  342. cout << "Code\t\t Dessert\t\t\t\tPrice\n__________________________________________________________________" << endl;
  343. for (i = 0; i < d; i++){
  344. cout << setw(20) << "\n" << code3[i];
  345. cout << " ";
  346. cout << setw(20) << dessert[i];
  347. cout << " ";
  348. cout << setw(30) << price3[i];
  349. cout << " ";
  350. cout << endl;
  351. }
  352.  
  353. cout << "What is your dessert? " << endl;
  354. cin >> test3;
  355. for (int y = 0; y < 15; y++)
  356. {
  357. if (test3 == code3[y])
  358. {
  359. cout << "How many? ";
  360. cin >> qty3;
  361. pr3 = qty3 * price3[y];
  362.  
  363.  
  364. y = 15;
  365. }
  366. }
  367. cout << "\nAMOUNT TO PAY:";
  368. cout << pr3 << endl;
  369. }
  370.  
  371.  
  372. else if (choice1 == 4){
  373.  
  374. total = pr1 + pr2 + pr3;
  375. cout << "\n\n\n\nTOTAL PRICE TO PURCHASE: " << total << endl;
  376. cout << "\n\nAnother transaction?[Y/N]:";
  377. cin >> reply1;
  378.  
  379. if (reply1 == 'y' || reply1 == 'Y')
  380. {
  381. pr1 = 0;
  382. pr2 = 0;
  383. pr3 = 0;
  384.  
  385. cout << "\n\n\nANOTHER TRANSACTION" << endl;
  386.  
  387. }
  388. else {
  389. system("cls");
  390. cout << "\n\n\t\t\t\tTHANK YOU " << endl;
  391. cout << "\n\n\n\nPRESS[5] TO EXIT\n\n" << endl;
  392.  
  393. }//elsesaloob
  394. }
  395. else
  396. {
  397. system("cls");
  398. cout << "Thank you!" << endl;
  399. }
  400. }//for loop
  401. return 0;
  402. }
  403.  
  404. int displaycase5()
  405. {
  406. system("cls");
  407. cout << "\n\n\t\t\t Search Order\n";
  408. cout << "Which order do you want to search?\n";
  409. cout << "[1]MEAL\n[2]D­RINKS\n[3]DESSERT";
  410. cout << "\nChoose:";
  411. cin >> order;
  412. switch (order){//nested switch
  413. case 1:
  414. system("cls");
  415. cout << "MEAL" << endl;
  416. cout << "Enter code : ";
  417. cin >> search;
  418. for (int i = 0; i < 15; i++)
  419. {
  420. if (search == code[i])
  421. {
  422. cout << "MEAL: " << meal[i] << "\n" << "PRICE: " << price[i] << "\n";
  423. i = 15;
  424.  
  425. }
  426.  
  427. }//loop case 1
  428. break;
  429. case 2:
  430. system("cls");
  431. cout << "Drinks" << endl;
  432. cout << "Enter code : ";
  433. cin >> search2;
  434. for (int i = 0; i < 15; i++)
  435. {
  436. if (search2 == code2[i])
  437. {
  438. cout << "DRINKS: " << drinks[i] << "\n" << "PRICE: " << price2[i] << "\n";
  439. i = 15;
  440.  
  441. }
  442.  
  443. }//loop case 2
  444. break;
  445. case 3:
  446. system("cls");
  447.  
  448. cout << "Dessert" << endl;
  449. cout << "Enter code : ";
  450. cin >> search3;
  451. for (int i = 0; i < 15; i++)
  452. {
  453. if (search3 == code3[i])
  454. {
  455. cout << "DESSERT: " << dessert[i] << "\n" << "PRICE: " << price3[i] << "\n";
  456. i = 15;
  457.  
  458. }
  459.  
  460. }//loop case 3
  461. break;
  462.  
  463.  
  464. }//end of switch inside case 5
  465. return 0;
  466. }
  467. //end of function
  468.  
  469. int main()
  470.  
  471. {//main
  472.  
  473. cout << "%%%%%%%%%%%%%%%%%%%%%%%" << endl;
  474. cout << "WELCOME TO JACDO" << endl;
  475. cout << "%%%%%%%%%%%%%%%%%%%%%%%" << endl;
  476.  
  477. while (reply == 'y' || reply == 'Y'){//while
  478. cout << "--------------------" << endl;
  479. cout << "[1]Add Meal\n[2]Display your meal\n[3]Update\n[4]Purchase\n[5]Search\n";
  480. cout << "--------------------" << endl;
  481.  
  482. cout << "Choose: ";
  483. cin >> choice;
  484. switch (choice){
  485. case 1:
  486. displaycase1();
  487. break;
  488. case 2:
  489. displaycase2();
  490. break;
  491. case 3:
  492. displaycase3();
  493. break;
  494.  
  495. case 4:
  496. displaycase4();
  497. break;
  498.  
  499. case 5:
  500. displaycase5();
  501. break;
  502.  
  503. default:
  504. {
  505. system("cls");
  506. cout << "INVALID! Please try again!" << endl;
  507. }
  508.  
  509.  
  510. }//switch
  511.  
  512. }//while
  513.  
  514. cout << "Do you want another transaction[y/n]?";
  515. cin >> reply;
  516. if (reply == 'n' || reply == 'N'){
  517. cout << "Thank you";
  518. }
  519.  
  520.  
  521. _getch();
  522. }//main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement