About my Project: MeatShop

Reply

Join Date: Jan 2009
Posts: 28
Reputation: moonw3ll is an unknown quantity at this point 
Solved Threads: 1
moonw3ll's Avatar
moonw3ll moonw3ll is offline Offline
Light Poster

About my Project: MeatShop

 
0
  #1
Mar 22nd, 2009
My question is: If i'm the customer, how can i edit the quantity shown on the overview so that i can afford to pay the totalprice(if i've ordered too much) and delete some on the overview if i want to delete it(really short on money).

And if i'm the owner of my meatshop, how can i see what products have been sold and the quantity?

I want to do this on my own but i can't seem to think of a way to do this. Hope someone can help me with this.

here's my code..

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <ctype.h>
  5. #define TAX_RATE 0.12
  6. #define MAX 23
  7. #define LENGTH 30
  8.  
  9. struct menuItemType
  10. {
  11. char menuItem[LENGTH];
  12. float menuPrice;
  13. float Total;
  14. float numOrdered;
  15. }theMenu[MAX];
  16.  
  17.  
  18. void initialize(void);
  19. int menu(void);
  20. void lamb(void);
  21. void beef(void);
  22. void pork(void);
  23. float order(void);
  24. void utro(void);
  25. void overView(void);
  26. void resibo(void);
  27. float edit(int);
  28.  
  29. int choice;
  30. int or_num = 100;
  31. float pbill=0;
  32. float bill=0;
  33. float totalTax=0;
  34. float totalItems=0;
  35. int y;
  36. float change;
  37. float pay=0;
  38.  
  39. int main(void)
  40. {
  41. int choyz;
  42. do
  43. {
  44. choyz = menu();
  45.  
  46. if(choyz==1) lamb();
  47. else if(choyz==2) pork();
  48. else if(choyz==3) beef();
  49. else if(choyz==4) gotoxy(30,16);textcolor(WHITE);
  50. printf("Salamat Lamang!");getch();textmode(LASTMODE); exit();
  51. }while(choyz<1 || choyz >4);
  52.  
  53. }
  54.  
  55.  
  56. /* Initialize */
  57.  
  58.  
  59. void initialize(void){
  60.  
  61. for (y = 0; y <= MAX; y++)
  62. {
  63. theMenu[y].numOrdered = 0;
  64. theMenu[y].Total = 0;
  65. theMenu[y].menuPrice = 0;
  66. strcpy(theMenu[y].menuItem,"");
  67. }
  68.  
  69. }
  70.  
  71.  
  72.  
  73. /* MAIN MENU */
  74.  
  75. int menu(void){
  76. clrscr();
  77. choice=0;
  78.  
  79. do{
  80. gotoxy(25,3);printf("ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»");
  81. gotoxy(25,4);printf("º PORKY'S MEAT SHOP º");
  82. gotoxy(25,5);printf("ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ");
  83.  
  84. gotoxy(33,8);printf("[1] Lamb");
  85. gotoxy(33,9);printf("[2] Pork");
  86. gotoxy(33,10);printf("[3] Beef");
  87. gotoxy(33,12);printf("[4] Exit");
  88. gotoxy(30,14);textcolor(BLACK);textbackground(WHITE);cprintf("Enter Choice:");
  89. choice = getch();
  90. textmode(LASTMODE);
  91. }while(choice<1 || choice>4);
  92. return choice;
  93. }
  94.  
  95.  
  96. /* LAMB */
  97.  
  98. void lamb(void){
  99. clrscr();
  100.  
  101. do{
  102. gotoxy(19,5);printf("[1]Lamb Chops P 120.00");
  103. gotoxy(19,6);printf("[2]Lamb Stew P 110.00");
  104. gotoxy(19,7);printf("[3]Lamb Shank P 140.00");
  105. gotoxy(19,8);printf("[4]Lamb Leg P 120.00");
  106. gotoxy(19,9);printf("[5]Lamb Rack P 170.00");
  107. gotoxy(19,10);printf("[6]Midloin Chops P 150.00");
  108. gotoxy(19,11);printf("[7]Rib of Lamb P 140.00");
  109. gotoxy(19,13);printf("[8]Back to Main");
  110.  
  111. gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
  112. choice = getch();
  113.  
  114. }while(choice<1 || choice>8);
  115. textmode(LASTMODE);
  116.  
  117. choice-=1;
  118.  
  119. switch(choice){
  120.  
  121. case 0: strcpy(theMenu[choice].menuItem,"Lamb Chops");
  122. theMenu[choice].menuPrice=120.00;
  123. theMenu[choice].numOrdered=order();
  124. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  125. utro();
  126. break;
  127. case 1: strcpy(theMenu[choice].menuItem,"Lamb Stew");
  128. theMenu[choice].menuPrice=110.00;
  129. theMenu[choice].numOrdered=order();
  130. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  131. utro();
  132. break;
  133. case 2: strcpy(theMenu[choice].menuItem,"Lamb Shank");
  134. theMenu[choice].menuPrice=140.00;
  135. theMenu[choice].numOrdered=order();
  136. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  137. utro();
  138. break;
  139. case 3: strcpy(theMenu[choice].menuItem,"Lamb Leg");
  140. theMenu[choice].menuPrice=120.00;
  141. theMenu[choice].numOrdered=order();
  142. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  143. utro();
  144. break;
  145. case 4: strcpy(theMenu[choice].menuItem,"Lamb Rack");
  146. theMenu[choice].menuPrice=170.00;
  147. theMenu[choice].numOrdered=order();
  148. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  149. utro();
  150. break;
  151. case 5: strcpy(theMenu[choice].menuItem,"Midloin Chops");
  152. theMenu[choice].menuPrice=150.00;
  153. theMenu[choice].numOrdered=order();
  154. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  155. utro();
  156. break;
  157. case 6: strcpy(theMenu[choice].menuItem,"Rib of Lamb");
  158. theMenu[choice].menuPrice=140.00;
  159. theMenu[choice].numOrdered=order();
  160. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  161. utro();
  162. break;
  163. default: main();
  164. break;
  165. }
  166.  
  167. }
  168.  
  169.  
  170. /* PORK */
  171. void pork(void){
  172. clrscr();
  173.  
  174. do{
  175. gotoxy(19,5);printf("[1]Tenderloin P 220.00");
  176. gotoxy(19,6);printf("[2]Pork Sukiyaki P 250.00");
  177. gotoxy(19,7);printf("[3]Butterfly Cut P 210.00");
  178. gotoxy(19,8);printf("[4]Pork Cutlets P 180.00");
  179. gotoxy(19,9);printf("[5]Porkchop P 260.00");
  180. gotoxy(19,10);printf("[6]Bacon Slice P 300.00");
  181. gotoxy(19,11);printf("[7]Pork Steak P 200.00");
  182. gotoxy(19,13);printf("[8]Back to Main");
  183.  
  184. gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
  185. choice = getch();
  186.  
  187. }while(choice<1 || choice>8);
  188. textmode(LASTMODE);
  189.  
  190. choice+=7;
  191.  
  192. switch(choice){
  193.  
  194. case 8: strcpy(theMenu[choice].menuItem,"Tenderloin");
  195. theMenu[choice].menuPrice=220.00;
  196. theMenu[choice].numOrdered=order();
  197. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  198. utro();
  199. break;
  200. case 9: strcpy(theMenu[choice].menuItem,"Pork Sukiyaki");
  201. theMenu[choice].menuPrice=250.00;
  202. theMenu[choice].numOrdered=order();
  203. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  204. utro();
  205. break;
  206. case 10: strcpy(theMenu[choice].menuItem,"Butterfly Cut");
  207. theMenu[choice].menuPrice=210.00;
  208. theMenu[choice].numOrdered=order();
  209. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  210. utro();
  211. break;
  212. case 11: strcpy(theMenu[choice].menuItem,"Pork Cutlets");
  213. theMenu[choice].menuPrice=180.00;
  214. theMenu[choice].numOrdered=order();
  215. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  216. utro();
  217. break;
  218. case 12: strcpy(theMenu[choice].menuItem,"Porkchop");
  219. theMenu[choice].menuPrice=260.00;
  220. theMenu[choice].numOrdered=order();
  221. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  222. utro();
  223. break;
  224. case 13: strcpy(theMenu[choice].menuItem,"Bacon Slice");
  225. theMenu[choice].menuPrice=300.00;
  226. theMenu[choice].numOrdered=order();
  227. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  228. utro();
  229. break;
  230. case 14: strcpy(theMenu[choice].menuItem,"Pork Steak");
  231. theMenu[choice].menuPrice=200.00;
  232. theMenu[choice].numOrdered=order();
  233. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  234. utro();
  235. break;
  236. default: main();
  237. break;
  238. }
  239. }
  240.  
  241.  
  242. /* BEEF */
  243. void beef(void){
  244. clrscr();
  245.  
  246.  
  247. do{
  248. gotoxy(19,5);printf("[1]Tenderloin P 200.00");
  249. gotoxy(19,6);printf("[2]Striploin P 210.00");
  250. gotoxy(19,7);printf("[3]Stroganoff P 230.00");
  251. gotoxy(19,8);printf("[4]Morcon Slice P 290.00");
  252. gotoxy(19,9);printf("[5]Beef Cubes P 200.00");
  253. gotoxy(19,10);printf("[6]Beef Steak P 230.00");
  254. gotoxy(19,11);printf("[7]Sirloin P 225.00");
  255. gotoxy(19,13);printf("[8]Back to Main");
  256.  
  257. gotoxy(33,15);textcolor(BLUE);textbackground(WHITE);cprintf("Enter Choice: ");
  258. choice = getch();
  259.  
  260. }while(choice<1 || choice>8);
  261. textmode(LASTMODE);
  262.  
  263. choice+=15;
  264.  
  265. switch(choice){
  266.  
  267. case 16: strcpy(theMenu[choice].menuItem,"Tenderloin");
  268. theMenu[choice].menuPrice=200.00;
  269. theMenu[choice].numOrdered=order();
  270. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  271. utro();
  272. break;
  273. case 17: strcpy(theMenu[choice].menuItem,"Striploin");
  274. theMenu[choice].menuPrice=210.00;
  275. theMenu[choice].numOrdered=order();
  276. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  277. utro();
  278. break;
  279. case 18: strcpy(theMenu[choice].menuItem,"Stroganoff");
  280. theMenu[choice].menuPrice=230.00;
  281. theMenu[choice].numOrdered=order();
  282. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  283. utro();
  284. break;
  285. case 19: strcpy(theMenu[choice].menuItem,"Morcon Slice");
  286. theMenu[choice].menuPrice=290.00;
  287. theMenu[choice].numOrdered=order();
  288. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  289. utro();
  290. break;
  291. case 20: strcpy(theMenu[choice].menuItem,"Beef Cubes");
  292. theMenu[choice].menuPrice=200.00;
  293. theMenu[choice].numOrdered=order();
  294. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  295. utro();
  296. break;
  297. case 21: strcpy(theMenu[choice].menuItem,"Beef Steak");
  298. theMenu[choice].menuPrice=230.00;
  299. theMenu[choice].numOrdered=order();
  300. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  301. utro();
  302. break;
  303. case 22: strcpy(theMenu[choice].menuItem,"Sirloin");
  304. theMenu[choice].menuPrice=225.00;
  305. theMenu[choice].numOrdered=order();
  306. theMenu[choice].Total= (theMenu[choice].menuPrice * theMenu[choice].numOrdered);
  307. utro();
  308. break;
  309. default: main();
  310. break;
  311. }
  312. }
  313.  
  314.  
  315.  
  316. /* ORDER */
  317.  
  318.  
  319. float order(void)
  320. {
  321. float g;
  322.  
  323.  
  324. do{
  325. gotoxy(33,17);printf("How many kilos? ");
  326. scanf("%f",&g);
  327. }while(g<0);
  328.  
  329. return g;
  330.  
  331. }
  332.  
  333. /* UTRO */
  334. void utro(void){
  335. char again;
  336.  
  337. do{
  338. gotoxy(33,19);printf("Order Again? (Y/N)");
  339. again = getch();
  340.  
  341. again=toupper(again);
  342.  
  343. }while(again!='Y' && again!='N');
  344. if(again=='Y') main();
  345. else overView();
  346. }
  347.  
  348. /* overView */
  349.  
  350.  
  351. void overView(void)
  352. {
  353. char what;
  354. int k=0;
  355. clrscr();
  356.  
  357. gotoxy(34,3);printf("ÉÍÍÍÍÍÍÍÍÍÍ»");
  358. gotoxy(34,4);printf("º Overview º");
  359. gotoxy(34,5);printf("ÈÍÍÍÍÍÍÍÍÍͼ");
  360.  
  361.  
  362.  
  363. gotoxy(5,7);printf("#");
  364. gotoxy(10,7);printf("Quantity");
  365. gotoxy(32,7);printf("Item");
  366. gotoxy(55,7);printf("Price");
  367. gotoxy(70,7);printf("Subtotal\n");
  368.  
  369. for (y = 0; y <= MAX; y++)
  370. {
  371. if (theMenu[y].numOrdered > 0)
  372. {
  373. gotoxy(5,9+k);printf("%d",k+1);
  374. gotoxy(10,9+k);printf("%.2f",theMenu[y].numOrdered);
  375. gotoxy(29,9+k);printf("%s",theMenu[y].menuItem);
  376. gotoxy(55,9+k);printf("P %.2f",theMenu[y].menuPrice);
  377. gotoxy(70,9+k);printf("P %2.2f",theMenu[y].Total);
  378. k++;
  379. }
  380. }
  381.  
  382. for(y = 0; y <= MAX; y++)
  383. {
  384. if (theMenu[y].Total>0)
  385. bill+=theMenu[y].Total;
  386. if (theMenu[y].numOrdered>0)
  387. totalItems+=theMenu[y].numOrdered;
  388. }
  389.  
  390.  
  391.  
  392. do{
  393. gotoxy(5,MAX);printf("Total Items: %-2.2f",totalItems);
  394. gotoxy(62,MAX);printf("Total : P %.2f",bill);
  395. gotoxy(30,MAX);printf("Continue? (Y/N)");
  396. what = getch();
  397.  
  398. what=toupper(what);
  399.  
  400. }while(what!='Y' && what!='N');
  401.  
  402. if (what=='Y'){
  403. gotoxy(30,MAX+1);printf("Enter Cash Amount: ");
  404. scanf("%f",&pay);
  405.  
  406. if (isdigit(pay)==1)
  407. {
  408. if (pay<bill)
  409. {
  410. printf("\n\t\t\tInsufficient funds!"); getch();
  411. overView();
  412.  
  413. }else{
  414. change = pay - bill;
  415. totalTax = bill * TAX_RATE;
  416. pbill = bill - totalTax;
  417. resibo();
  418. getch();
  419. }
  420.  
  421. }else{
  422. printf("Only Numbers allowed"); getch();
  423. overView();
  424. }else main();
  425.  
  426.  
  427. }
  428.  
  429.  
  430. /* RESIBO */
  431.  
  432. void resibo(void){
  433. clrscr();
  434.  
  435.  
  436.  
  437. gotoxy(31,2);printf("PORKY'S MEAT SHOP");
  438. gotoxy(30,3);printf("Agora Road, Disneyland");
  439. gotoxy(28,5);printf("------------------------------\n\n");
  440.  
  441. gotoxy(28,7);printf("VATABLE Sales : %11.2f",pbill);
  442. gotoxy(28,8);printf("VAT Amount : %11.2f",totalTax);
  443. gotoxy(28,9);printf("Amount Due : %11.2f",bill);
  444. gotoxy(28,10);printf("-------------------------------\n\n");
  445.  
  446. gotoxy(28,12);printf("Cash : %10.2f",bill);
  447. gotoxy(28,13);printf("Change : %10.2f",change);
  448. gotoxy(28,14);printf("TotalItems : %10.2f",totalItems);
  449. gotoxy(28,15);printf("OR # : %10d",or_num);
  450. or_num++;
  451. getch();
  452. initialize();
  453. main();
  454. }
Last edited by moonw3ll; Mar 22nd, 2009 at 2:04 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 124
Reputation: kenji is an unknown quantity at this point 
Solved Threads: 9
kenji's Avatar
kenji kenji is offline Offline
Junior Poster

Re: About my Project: MeatShop

 
0
  #2
Mar 22nd, 2009
You need to use an int to keep the number of items sold. Also use a switch/case to choose whether customer or owner.
And she said "Let there be light" and on the seveth day Windows booted.
And the crowds screamed in terror and cowered in fear for Microsoft had approached.
From the testament of 10011101
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 28
Reputation: moonw3ll is an unknown quantity at this point 
Solved Threads: 1
moonw3ll's Avatar
moonw3ll moonw3ll is offline Offline
Light Poster

Re: About my Project: MeatShop

 
0
  #3
Mar 22nd, 2009
Originally Posted by kenji View Post
You need to use an int to keep the number of items sold. Also use a switch/case to choose whether customer or owner.
I can't use int, what if the customer will order 2.5 kilos? and... the customer-owner things is done.. what i need is how to edit the overview and how to put info on a file(file handling).
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 241
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: About my Project: MeatShop

 
0
  #4
Mar 22nd, 2009
>My question is: If i'm the customer, how can i edit the quantity shown on the overview so that i can afford to pay the totalprice(if i've ordered too much) and delete some on the overview if i want to delete it(really short on money).

Well, you can display all your menu with the corresponding values next to it. And at the bottom of the above menu you could have one more horizon menu with the C-Calculate, D-Delete etc etc. This would allow the user to edit the qty value and to re-calculate the price press ‘C’ and that your probably clear the screen the then display the new value or the updated value. Or you don’t have to clear the screen. Perhaps, just update the value at the x & y position. Since, they are more fixed in your case.

>And if i'm the owner of my meatshop, how can i see what products have been sold and the quantity?
Well, if you wanted to use files handling, then probably you will have to record all the details of qty and the total price for each transaction. Its up to you on how do you want to write them onto the file.

1. Place them in the structure and then write the structure.
2. You could store them in a variable and then write the variable to the file.

If you want to know more about the file handling google file handling in C.

There are few things which I will have to point out before anything can be said. It looks like that your using library functions which are not portable. Especially the conio.h and function defined under that library are not portable. You should seriously think of upgrading your compiler. Use Dev-C++ or the Code:Block. Then both use the mingW port which connects to the GCC.

And also that show snap shorts of your code on where you need help. Rather then posting them all here. That’s that helpful and you wouldn’t get much help

-ssharish
"Any fool can know, point is to understand"
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 28
Reputation: moonw3ll is an unknown quantity at this point 
Solved Threads: 1
moonw3ll's Avatar
moonw3ll moonw3ll is offline Offline
Light Poster

Re: About my Project: MeatShop

 
0
  #5
Mar 24th, 2009
Originally Posted by ssharish2005 View Post

Well, you can display all your menu with the corresponding values next to it. And at the bottom of the above menu you could have one more horizon menu with the C-Calculate, D-Delete etc etc. This would allow the user to edit the qty value and to re-calculate the price press ‘C’ and that your probably clear the screen the then display the new value or the updated value. Or you don’t have to clear the screen. Perhaps, just update the value at the x & y position. Since, they are more fixed in your case.
If the user wants to delete, then he/she will change the quantity to 0.

Originally Posted by ssharish2005 View Post


There are few things which I will have to point out before anything can be said. It looks like that your using library functions which are not portable. Especially the conio.h and function defined under that library are not portable. You should seriously think of upgrading your compiler. Use Dev-C++ or the Code:Block. Then both use the mingW port which connects to the GCC.
My instructor wants to use the very basic Borland v2.01. He wants us to learn the basic first before using high level programming languages.

Originally Posted by ssharish2005 View Post
And also that show snap shorts of your code on where you need help. Rather then posting them all here. That’s that helpful and you wouldn’t get much help
-ssharish
Ok I will do this the next time i post.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC