I'd like to make very simple cash register program. I have no idea why my program skips the user input for item2, then it jumped to Quantity2 and Price2, and cash, then the program stop without calculating anything. Please help me. Thanks in advance.
/*Cash register*/
#include <stdio.h>
int main () {
char Item1 [10], Item2 [10];
int Price1, Price2, Quantity1, Quantity2, Cash, Total1, Total2, Subtotal, Tax, Total, Change;
printf ("Welcome to Sejahtera Electronics Store \n");
printf ("Please input your items, quantities, and price of each item: \n");
printf("Item 1: ");
fgets (Item1, 10, stdin);
printf("Quantity: ");
scanf("%i", &Quantity1);
printf("Price: ");
scanf("%i", &Price1);
printf("Item 2: \n");
fgets (Item2, 10, stdin);
printf("Quantity: ");
scanf ("%i", &Quantity2);
printf("Price: ");
scanf ("%i", &Price2);
printf ("Input your cash: $");
scanf ("%i", Cash);
Total1=Quantity1*Price1;
Total2=Quantity2*Price2;
Subtotal=Total1+Total2;
Tax=Subtotal*0.1;
Total=Subtotal+Tax;
Change=Cash-Total;
printf ("Subtotal: $%i", &Subtotal);
printf ("Tax: $%i", &Tax);
printf ("Total: $%i", &Total);
printf ("Change: $%i", &Change);
return 0;
}
Output: Welcome to Sejahtera Electronics Store Please input your items, quantities, and price of each item: Item 1: wire Quantity: 5 Price: 5 **Item 2: ** *the program skip this part so I can only insert the quantity and price for item 2 Quantity: 5 Price: 5 Input your cash: $50000 *program stops here, it supposed to calculate the subtotal, tax, total, and change