Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. //Program Code
  2. #include<stdio.h>
  3. #include<conio.h>
  4. void menu();
  5. void combination();
  6. void calorie();
  7. struct banana
  8. {
  9. char *nb;
  10. int pb;
  11. int cb;
  12. int fb;
  13. };
  14. struct oranges
  15. {
  16. char *no;
  17. int po;
  18. int co;
  19. int fo;
  20. };
  21. struct bread
  22. {
  23. char *nbr;
  24. int pbr;
  25. int cbr;
  26. int fbr;
  27. };
  28. struct milk
  29. {
  30. char *nm;
  31. int pm;
  32. int cm;
  33. int fm;
  34. };
  35. struct sceggs
  36. {
  37. char *nse;
  38. int pse;
  39. int cse;
  40. int fse;
  41. };
  42. struct cflakes
  43. {
  44. char *ncf;
  45. int pcf;
  46. int ccf;
  47. int fcf;
  48. };
  49. struct vbsoup
  50. {
  51. char *nvbs;
  52. int pvbs;
  53. int cvbs;
  54. int fvbs;
  55. };
  56. struct tsoup
  57. {
  58. char *nts;
  59. int cts;
  60. int pts;
  61. int fts;
  62. };
  63. struct oranges o;
  64. struct bread br;
  65. struct milk m;
  66. struct sceggs se;
  67. struct cflakes cf;
  68. struct vbsoup vbs;
  69. struct tsoup ts;
  70. struct banana b;
  71. void main()
  72. {
  73. clrscr();
  74. int a;
  75. char c;
  76. b.nb="BANANA";
  77. b.pb=20;
  78. b.cb=105;
  79. b.fb=1;
  80. o.no="ORANGES";
  81. o.po=20;
  82. o.co=62;
  83. o.fo=0;
  84. br.nbr=" WHEAT BREAD";
  85. br.pbr=40;
  86. br.cbr=65;
  87. br.fbr=1;
  88. m.nm="SKIMMED MILK";
  89. m.pm=30;
  90. m.cm=86;
  91. m.fm=1;
  92. se.nse="SCRAMBLED EGGS";
  93. se.pse=20;
  94. se.cse=100;
  95. se.fse=7;
  96. cf.ncf="CORNFLAKES";
  97. cf.pcf=20;
  98. cf.ccf=111;
  99. cf.fcf=0;
  100. vbs.nvbs="VEGETBEEF SOUP";
  101. vbs.pvbs=100;
  102. vbs.cvbs=158;
  103. vbs.fvbs=4;
  104. ts.nts="TOMATO SOUP";
  105. ts.pts=30;
  106. ts.cts=171;
  107. ts.fts=4;
  108. d:
  109. printf("Enter Your Choice:");
  110. printf("\n1. Menu");
  111. printf("\n2. Enter your budget to get the best combination");
  112. printf("\n3. Diet meal");
  113. printf("\n4. Exit ");
  114. scanf("%d",&a);
  115. switch (a)
  116. {
  117. case 1:
  118. menu();
  119. break;
  120. case 2:
  121. combination();
  122. break;
  123. case 3:
  124. calorie();
  125. break;
  126. case 4:
  127. printf("Thank You!");
  128. goto f;
  129. break;
  130. default:
  131. printf("Wrong choice entered!");
  132. }
  133. printf("\nIf you want to enter choice again? yes(y)/no(n)");
  134. scanf("%s",&c);
  135. if(c=='y')
  136. {
  137. goto d;
  138. }
  139. else
  140. {
  141. printf("Thank You!");
  142. }
  143. f:
  144. getch();
  145. }
  146. void menu()
  147. {
  148. printf("****MENU****");
  149. printf("\nITEM");
  150. printf("\t\tPRICE");
  151. printf("\t\tCALORIES");
  152. printf("\tFAT");
  153. printf("\n%s",b.nb);
  154. printf("\t\tRs.%d",b.pb);
  155. printf("\t\t%d",b.cb);
  156. printf("\t\t%dg",b.fb);
  157. printf("\n%s",o.no);
  158. printf("\t\tRs.%d",o.po);
  159. printf("\t\t%d",o.co);
  160. printf("\t\t%dg",o.fo);
  161. printf("\n%s",br.nbr);
  162. printf("\tRs.%d",br.pbr);
  163. printf("\t\t%d",br.cbr);
  164. printf("\t\t%dg",br.fbr);
  165. printf("\n%s",m.nm);
  166. printf("\tRs.%d",m.pm);
  167. printf("\t\t%d",m.cm);
  168. printf("\t\t%dg",m.fm);
  169. printf("\n%s",se.nse);
  170. printf("\tRs.%d",se.pse);
  171. printf("\t\t%d",se.cse);
  172. printf("\t\t%dg",se.fse);
  173. printf("\n%s",cf.ncf);
  174. printf("\tRs.%d",cf.pcf);
  175. printf("\t\t%d",cf.ccf);
  176. printf("\t\t%dg",cf.fcf);
  177. printf("\n%s",vbs.nvbs);
  178. printf("\tRs.%d",vbs.pvbs);
  179. printf("\t\t%d",vbs.cvbs);
  180. printf("\t\t%dg",vbs.fvbs);
  181. printf("\n%s",ts.nts);
  182. printf("\tRs.%d",ts.pts);
  183. printf("\t\t%d",ts.cts);
  184. printf("\t\t%dg",ts.fts);
  185. }
  186. void combination()
  187. {
  188. int x, cost, total;
  189. printf("\nEnter your budget in multiples of Rs.50:");
  190. scanf("%d",&x);
  191. if(x==50)
  192. {
  193. cost=ts.pts+se.pse;
  194. total=ts.cts+se.cse;
  195. printf("The best combination is:");
  196. printf("\n%s and %s",ts.nts,se.nse);
  197. printf("\nTotal price=%d",cost);
  198. printf("\nTotal calories=%d",total);
  199. }
  200. else if(x==100)
  201. {
  202. cost=m.pm+cf.pcf+ts.pts+b.pb;
  203. total=m.cm+cf.ccf+ts.cts+b.cb;
  204. printf("The best combination is:");
  205. printf("\n%s, %s, %s and %s",m.nm,cf.ncf,ts.nts,b.nb);
  206. printf("\nTotal price=%d",cost);
  207. printf("\nTotal calories=%d",total);
  208. }
  209. else if(x==150)
  210. {
  211. cost=vbs.pvbs+se.pse+m.pm;
  212. total=vbs.cvbs+se.cse+m.cm;
  213. printf("The best combination is:");
  214. printf("\n%s, %s and %s",vbs.nvbs,se.nse,m.nm);
  215. printf("\nTotal price=%d",cost);
  216. printf("\nTotal calories=%d",total);
  217. }
  218. else if(x==200)
  219. {
  220. cost=vbs.pvbs+br.pbr+se.pse+b.pb;
  221. total=vbs.cvbs+br.cbr+se.cse+b.cb;
  222. printf("The best combination is:");
  223. printf("\n%s, %s, %s and %s",vbs.nvbs,br.nbr,se.nse,b.nb);
  224. printf("\nTotal price=%d",cost);
  225. printf("\nTotal calories=%d",total);
  226. }
  227. else if(x==250)
  228. {
  229. cost=vbs.pvbs+cf.pcf+m.pm+o.po+br.pbr;
  230. total=vbs.cvbs+cf.ccf+m.cm+o.co+br.cbr;
  231. printf("The best combination is:");
  232. printf("\n%s, %s, %s, %s and %s",vbs.nvbs,cf.ncf,m.nm,o.no,br.nbr);
  233. printf("\nTotal price=%d",cost);
  234. printf("\nTotal calories=%d",total);
  235. }
  236. else if(x>=300)
  237. {
  238. cost=m.pm+cf.pcf+vbs.pvbs+se.pse;
  239. total=m.cm+cf.ccf+vbs.cvbs+se.cse;
  240. printf("The best combination is:");
  241. printf("\n%s, %s, %s and %s",m.nm,cf.ncf,vbs.nvbs,se.nse);
  242. printf("\nTotal price=%d",cost);
  243. printf("\nTotal calories=%d",total);
  244. }
  245. }
  246. void calorie()
  247. {
  248. int cost1, total1;
  249. cost1=vbs.pvbs+se.pse+br.pbr+o.po;
  250. total1=vbs.cvbs+se.cse+br.cbr+o.co;
  251. printf("The best combination with minimum calories is:");
  252. printf("%s, %s, %s and %s",vbs.nvbs,se.nse,br.nbr,o.no);
  253. printf("\nTotal price=%d",cost1);
  254. printf("\nTotal calories=%d",total1);
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement