Feb 9, 2011 at 7:12pm UTC
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int sum=0, choice;
printf("Option 1 CheeseBurger\n");
printf("Option 2 FishBurger\n");
printf("Option 3 VeggieBurger\n");
printf("Option 4 NoBurger\n");
scanf("%d" ,&choice);
if(choice==1) {printf("cheeseburger\n");sum=sum+461;}
if(choice==2) {printf("fishburger\n");sum=sum+431;}
if(choice==3) {printf ("veggieburger\n");sum=sum+420;}
if(choice==4) {printf ("no burger\n");sum=sum+0;}
printf("Option 5 Soft Drink\n");
printf("Option 6 Orange Juice\n");
printf("Option 7 Milk\n");
printf("Option 8 No Drink\n");
scanf("%d" ,&choice);
if(choice==1) {printf("Soft Drink\n");sum=sum+130;}
if(choice==2) {printf("Orange Juice\n");sum=sum+160;}
if(choice==3) {printf ("Milk\n");sum=sum+118;}
if(choice==4) {printf ("no Drink\n");sum=sum+0;}
printf("Option 9 Fries\n");
printf("Option 10 Baked Potato\n");
printf("Option 11 Chef Salad\n");
printf("Option 12 No Side\n");
scanf("%d" ,&choice);
if(choice==1) {printf("Fries\n");sum=sum+100;}
if(choice==2) {printf("Baked Potato\n");sum=sum+57;}
if(choice==3) {printf ("Chef salad\n");sum=sum+70;}
if(choice==4) {printf ("no Side\n");sum=sum+0;}
printf("Option 13 Apple Pie\n");
printf("Option 14 Sundae\n");
printf("Option 15 Fruit Cup\n");
printf("Option 16 No Dessert\n");
scanf("%d" ,&choice);
if(choice==1) {printf("Apple Pie\n");sum=sum+167;}
if(choice==2) {printf("Sundae\n");sum=sum+266;}
if(choice==3) {printf ("Fruit Cup\n");sum=sum+75;}
if(choice==4) {printf ("No Dessert\n");sum=sum+0;}
system("PAUSE");
return 0;
}
when all is said and done the program needs to add up all of the calories and display them once all choices have been chosen.
Feb 9, 2011 at 7:15pm UTC
You are using c, not c++ ;)
I really like your assignment, but it seems a bit restrictive...
Why not have a loop swing through your user input and give them the ability to add as many items as they want, you search a file for the item, and if it's in the database add it to the calorie count. If it's not in the file request the calorie count from the user?
Last edited on Feb 9, 2011 at 7:16pm UTC
Feb 9, 2011 at 7:18pm UTC
well we were told to do it this way so ima do it this way and we are programming it in c++ and i only started learning c 2 days ago so i need help and he said use the internet to help so im using this site
Feb 9, 2011 at 9:14pm UTC
Well what specifically are you having a problem with? I'm sure you would get lots of help with specific problems.
Like how do I store the user's input?
Feb 10, 2011 at 3:59pm UTC
what needs to happen is when i enter 1 then 5 then 9 then 13 it needs to total all of the calories thats what i need the code to do
Feb 10, 2011 at 7:00pm UTC
Awesome, sounds like you've got it covered.
Feb 10, 2011 at 7:01pm UTC
yup but now i have another task wondering if u could help me with that
Feb 10, 2011 at 7:24pm UTC
If you have any specific problems, i'm sure you'll get some help.