I basically have the majority of the program written out. But, for some reason the while statement will not end when the sentinel value (variable sentinelMeal) has been reached. Could somebody help me out with this? Do I need to take the 'meals=meals+quantity' out of the switch statement?
I am not getting any errors or warnings, so I think mostly everything is fine.
Thanks, any help is appreciated.
Code:#include <stdio.h>
int main ()
{
double meals=0;
double total=0;
int sentinelMeal;
int combo;
double quantity;
double subtotal;
printf("Please enter the number of meals you would like to order:");
scanf("%d",&sentinelMeal);
while(meals<=sentinelMeal) {
printf("Menu\n1) Hamburger, Fries, and drink...................$2.79\n2) Cheeseburger, Fries, and drink................$3.09\n3) Quarterpounder, Fries and drink...............$3.29\n4) Double Cheesburger, Fries, and drink..........$3.89\n5) Grilled Chicken Sandwich, Fries, and drink....$3.19\n6) Fish Sandwich, Fries, and drink...............$3.29\n");
printf("Enter meal combo number:\n");
scanf("%d",&combo);
printf("Please enter the quantity of this combo you would like to order");
scanf("%d",&quantity);
switch(combo) {
case'1':
subtotal=2.79*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
case'2':
subtotal=3.09*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
case'3':
subtotal=3.29*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
case'4':
subtotal=3.89*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
case'5':
subtotal=3.19*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
case'6':
subtotal=3.29*quantity;
total=total+subtotal;
meals=meals+quantity;
break;
}
}
printf("Purchase Receipt %d,total");
return 0;
}