You are on page 1of 2

#include<stdio.

h>
#include<conio.h>
main(){
float money=0,price=0,change=0,totalamount=0;
int howmany=0,transaction=1;
do{
printf("Enter the price: ");
scanf("%f",&price);
printf("Enter the quantity: ");
scanf("%d",&howmany);
totalamount=(price*howmany);
printf("\nThe Total Amount to be paid is P
%.2f",totalamount);
do{
printf("\nEnter payment by the customer: ");
scanf("%f",&money);
if(money<totalamount)
{
printf("\nThe payment is lower than the amount
to be paid.\n");
printf("Pay with an amount higher than the
total amount.\n");
}
else if(money>totalamount)
{
change=money-totalamount;
printf("\nThe change is P%.2f",change);
}
else if(money==totalamount){
printf("\nNo change needed.\n");
}
}while(money<totalamount);
printf("\nTransaction has ended. Press 1 to Make new
transaction or \nPress any key to end transaction.");
printf("\nEnter Decision: ");
scanf("%d",&transaction);
if(transaction==1){
printf("The transaction will now begin again.\n");

printf("\nPress any key to continue...");


getch();
clrscr();
}
else if(transaction!=0){
printf("The transaction will now end.");
}
}while(transaction==1);
getch();
}

You might also like