Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program Code
- #include<stdio.h>
- #include<conio.h>
- void menu();
- void combination();
- void calorie();
- struct banana
- {
- char *nb;
- int pb;
- int cb;
- int fb;
- };
- struct oranges
- {
- char *no;
- int po;
- int co;
- int fo;
- };
- struct bread
- {
- char *nbr;
- int pbr;
- int cbr;
- int fbr;
- };
- struct milk
- {
- char *nm;
- int pm;
- int cm;
- int fm;
- };
- struct sceggs
- {
- char *nse;
- int pse;
- int cse;
- int fse;
- };
- struct cflakes
- {
- char *ncf;
- int pcf;
- int ccf;
- int fcf;
- };
- struct vbsoup
- {
- char *nvbs;
- int pvbs;
- int cvbs;
- int fvbs;
- };
- struct tsoup
- {
- char *nts;
- int cts;
- int pts;
- int fts;
- };
- struct oranges o;
- struct bread br;
- struct milk m;
- struct sceggs se;
- struct cflakes cf;
- struct vbsoup vbs;
- struct tsoup ts;
- struct banana b;
- void main()
- {
- clrscr();
- int a;
- char c;
- b.nb="BANANA";
- b.pb=20;
- b.cb=105;
- b.fb=1;
- o.no="ORANGES";
- o.po=20;
- o.co=62;
- o.fo=0;
- br.nbr=" WHEAT BREAD";
- br.pbr=40;
- br.cbr=65;
- br.fbr=1;
- m.nm="SKIMMED MILK";
- m.pm=30;
- m.cm=86;
- m.fm=1;
- se.nse="SCRAMBLED EGGS";
- se.pse=20;
- se.cse=100;
- se.fse=7;
- cf.ncf="CORNFLAKES";
- cf.pcf=20;
- cf.ccf=111;
- cf.fcf=0;
- vbs.nvbs="VEGETBEEF SOUP";
- vbs.pvbs=100;
- vbs.cvbs=158;
- vbs.fvbs=4;
- ts.nts="TOMATO SOUP";
- ts.pts=30;
- ts.cts=171;
- ts.fts=4;
- d:
- printf("Enter Your Choice:");
- printf("\n1. Menu");
- printf("\n2. Enter your budget to get the best combination");
- printf("\n3. Diet meal");
- printf("\n4. Exit ");
- scanf("%d",&a);
- switch (a)
- {
- case 1:
- menu();
- break;
- case 2:
- combination();
- break;
- case 3:
- calorie();
- break;
- case 4:
- printf("Thank You!");
- goto f;
- break;
- default:
- printf("Wrong choice entered!");
- }
- printf("\nIf you want to enter choice again? yes(y)/no(n)");
- scanf("%s",&c);
- if(c=='y')
- {
- goto d;
- }
- else
- {
- printf("Thank You!");
- }
- f:
- getch();
- }
- void menu()
- {
- printf("****MENU****");
- printf("\nITEM");
- printf("\t\tPRICE");
- printf("\t\tCALORIES");
- printf("\tFAT");
- printf("\n%s",b.nb);
- printf("\t\tRs.%d",b.pb);
- printf("\t\t%d",b.cb);
- printf("\t\t%dg",b.fb);
- printf("\n%s",o.no);
- printf("\t\tRs.%d",o.po);
- printf("\t\t%d",o.co);
- printf("\t\t%dg",o.fo);
- printf("\n%s",br.nbr);
- printf("\tRs.%d",br.pbr);
- printf("\t\t%d",br.cbr);
- printf("\t\t%dg",br.fbr);
- printf("\n%s",m.nm);
- printf("\tRs.%d",m.pm);
- printf("\t\t%d",m.cm);
- printf("\t\t%dg",m.fm);
- printf("\n%s",se.nse);
- printf("\tRs.%d",se.pse);
- printf("\t\t%d",se.cse);
- printf("\t\t%dg",se.fse);
- printf("\n%s",cf.ncf);
- printf("\tRs.%d",cf.pcf);
- printf("\t\t%d",cf.ccf);
- printf("\t\t%dg",cf.fcf);
- printf("\n%s",vbs.nvbs);
- printf("\tRs.%d",vbs.pvbs);
- printf("\t\t%d",vbs.cvbs);
- printf("\t\t%dg",vbs.fvbs);
- printf("\n%s",ts.nts);
- printf("\tRs.%d",ts.pts);
- printf("\t\t%d",ts.cts);
- printf("\t\t%dg",ts.fts);
- }
- void combination()
- {
- int x, cost, total;
- printf("\nEnter your budget in multiples of Rs.50:");
- scanf("%d",&x);
- if(x==50)
- {
- cost=ts.pts+se.pse;
- total=ts.cts+se.cse;
- printf("The best combination is:");
- printf("\n%s and %s",ts.nts,se.nse);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- else if(x==100)
- {
- cost=m.pm+cf.pcf+ts.pts+b.pb;
- total=m.cm+cf.ccf+ts.cts+b.cb;
- printf("The best combination is:");
- printf("\n%s, %s, %s and %s",m.nm,cf.ncf,ts.nts,b.nb);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- else if(x==150)
- {
- cost=vbs.pvbs+se.pse+m.pm;
- total=vbs.cvbs+se.cse+m.cm;
- printf("The best combination is:");
- printf("\n%s, %s and %s",vbs.nvbs,se.nse,m.nm);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- else if(x==200)
- {
- cost=vbs.pvbs+br.pbr+se.pse+b.pb;
- total=vbs.cvbs+br.cbr+se.cse+b.cb;
- printf("The best combination is:");
- printf("\n%s, %s, %s and %s",vbs.nvbs,br.nbr,se.nse,b.nb);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- else if(x==250)
- {
- cost=vbs.pvbs+cf.pcf+m.pm+o.po+br.pbr;
- total=vbs.cvbs+cf.ccf+m.cm+o.co+br.cbr;
- printf("The best combination is:");
- printf("\n%s, %s, %s, %s and %s",vbs.nvbs,cf.ncf,m.nm,o.no,br.nbr);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- else if(x>=300)
- {
- cost=m.pm+cf.pcf+vbs.pvbs+se.pse;
- total=m.cm+cf.ccf+vbs.cvbs+se.cse;
- printf("The best combination is:");
- printf("\n%s, %s, %s and %s",m.nm,cf.ncf,vbs.nvbs,se.nse);
- printf("\nTotal price=%d",cost);
- printf("\nTotal calories=%d",total);
- }
- }
- void calorie()
- {
- int cost1, total1;
- cost1=vbs.pvbs+se.pse+br.pbr+o.po;
- total1=vbs.cvbs+se.cse+br.cbr+o.co;
- printf("The best combination with minimum calories is:");
- printf("%s, %s, %s and %s",vbs.nvbs,se.nse,br.nbr,o.no);
- printf("\nTotal price=%d",cost1);
- printf("\nTotal calories=%d",total1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement