I got problems regarding the minus operation in c.
printf("\nPlease enter your payment:\n", userpayment);
scanf("%.2f", &userpayment);
customerchange = userpayment - totalfinal;
printf("The amount of change is %.2f\n", customerchange);
I declared userpayment
and totalfinal
as double
.
Whenever I input the price for example; userpayment = 2000
and the totalfinal
is 1500, the output will always be 1500.
What is the solution to this?
This is the output:
Enter the Price of Item: 500 Enter Quantity of Item: 3 The total amount of Payment is: RM1500.00 Is this the last item? y Rm50 cash rebate has been given to the customer. Total Payment before cash rebate is: 1500 Total Payment after cash rebate is 1450
Please enter your payment: 5000 Your change is RM-14500.00