Code:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int chicken = 5; int amountOfChicken;
int fish = 3; int amountOfFish;
int eggs = 1; int amountOfEggs;
int fries = 4; int amountOfFries;
int rice = 1; int amountOfRice;
int amount;
char choice; char choice2;
printf("The Menu is the one below and type 0 to stop.\n");
printf("[A]Chicken = $5 [B]Fish = $3 [C]Eggs = $1 [D]Fries = $4 [E]Rice = $1\n\n");
do {
printf("Enter the letter for the food you want: ");
scanf(" %c", &choice);
if (choice == 'A' || choice == 'a') {
printf("You chose Chicken. How many do you want?\n");
printf("I want: ");
scanf(" %d", &amountOfChicken);
amountOfChicken *= chicken;
printf("That will be %d\n\n", amountOfChicken);
} else if (choice == 'B' ||choice == 'b') {
printf("You chose Fish. How many do you want?\n");
printf("I want: ");
scanf(" %d", &amountOfFish);
amountOfFish *= fish;
printf("That will be %d\n\n", amountOfFish);
} else if (choice == 'C' ||choice == 'c') {
printf("You chose Eggs. How many do you want?\n");
printf("I want: ");
scanf(" %d", &amountOfEggs);
amountOfEggs *= eggs;
printf("That will be %d\n\n", amountOfEggs);
} else if (choice == 'D' ||choice == 'd') {
printf("You chose Fries. How many do you want?\n");
printf("I want: ");
scanf(" %d", &amountOfFries);
amountOfFries *= fries;
printf("That will be %d\n\n", fish);
} else if (choice == 'E' ||choice == 'e') {
printf("You chose Rice. How many do you want?\n");
printf("I want: ");
scanf(" %d", &amountOfRice);
amountOfRice *= rice;
printf("That will be %d\n\n", amountOfRice);
} else {
printf("Error you typed wrong!\n\n");
break;
}
if (choice == 'A' || choice == 'a' || choice == 'B' || choice == 'b' || choice == 'C' || choice == 'c' || choice == 'D' || choice == 'd' || choice == 'E' || choice == 'e') {
printf ("Would you like to add more? Y/N\n");
scanf (" %c", &choice2);
}
if (choice2 == 'y' ||choice2 == 'Y') {
printf ("Choose which one to add again: \n\n [A]Chicken = $5 [B]Fish = $3 [C]Eggs = $1 [D]Fries = $4 [E]Rice = $1\n\n");
} else {
break;
}
} while (choice2 != 'N' ||choice2 == 'n');
if (choice == 'A' || choice == 'a' || choice == 'B' || choice == 'b' || choice == 'C' || choice == 'c' || choice == 'D' || choice == 'd' || choice == 'E' || choice == 'e') {
amount = amountOfChicken + amountOfEggs + amountOfFish + amountOfFries + amountOfRice;
printf ("The total is: $%d", amount);
}
return 0;
}
Okay this is my updated code. Now my problem is the amount and thanks Shadew. So that's why it terminates always. XD