I have a project for school where we have to create a menu for the user, then have the user select their item and loop the menu until the user types a certain character to exit the menu. Once they exit the menu, I need the program to print out what they ordered and how much their total is. I have everything working right except i cant figure out how to count the items they have ordered and print out their items at the end. Here is the code i have so far. Thank you for any help.
main(){
int choice = 0, pizzaSliceCount = 0, totalOrder;
double totalPrice = 0;
printf("Welcome to Chef Chris' Pizzeria. May I take your order?\n");
do{
printf("Please make your selection\n");
printf("1. Pizza Slice %.2lf\n", PIZZA_SLICE);
printf("2. Whole Pizza %.2lf\n", WHOLE_PIZZA);
printf("3. Pizza Sticks %.2lf\n", PIZZA_STICKS);
printf("4. Calzone %.2lf\n", CALZONE);
printf("5. Spaghetti and Meatballs %.2lf\n", SPAGHETTI_AND_MEATBALLS);
printf("6. Soft Drink %.2lf\n", SOFT_DRINK);
printf("7. Exit\n");
scanf("%i", &choice);
switch(choice){
case 1:
totalPrice+=PIZZA_SLICE;
break;
case 2:
totalPrice+=WHOLE_PIZZA;
break;
case 3:
totalPrice+=PIZZA_STICKS;
break;
case 4:
totalPrice+=CALZONE;
break;
case 5:
totalPrice+=SPAGHETTI_AND_MEATBALLS;
break;
case 6:
totalPrice+=SOFT_DRINK;
break;
case 7:
break;
default:
printf("This is not a menu item\n");
}
printf("\nYour total so far is %.2lf\n", totalPrice);
} while(choice!=7);
printf("\nThats %i\n",pizzaSliceCount);
printf("\nYour total is %.2lf\n", totalPrice);
The only problem is I cant use arrays because we havent learned them yet. Im taking a intro to programming class and i can only use what we have learned. I know i need to make seperate count variables for each menu item. I just dont know where to put the count in the loop and also how to output the final count of items at the end of the program.
The program output should look like this(different menu items)