I have C code which simulates contact-less checkout.
Enter value of your bill: 50 Insert money for payment: 50 20 5 0.10 0 You have inserted: 75.1 To return: 25.1
I have to achieve this:
Collect your payback: 20 5 0.10
I can use only use this nominal values:
float allowedMoney[13] = {100, 50, 20, 10, 5, 2, 1, 0.50, 0.20, 0.10, 0.05, 0.02 , 0.01};
Any idea how to do it? Thank you very much
main()
function
int main() {
float bill = getBill();
float payment = insertPayment();
if(!payment) return 1;
printf("You have inserted: %g\n", payment);
if(payment < bill) {
printf("Not enough money!\n");
return 1;
}
float toReturn = payment - bill;
printf("To return: %g\n", toReturn);
if(toReturn > 0) {
int payback = getPayback(toReturn);
print ... (HELP)
}
return 1;
}
EDIT: I have variable with value for example: 25.1
I have to output in one line this: 20 5 0.10 Thats the "20 Dollars + 5 Dollars + 10 Cents" I have to transfer number 25.1 to format of dollars and cents like this: 20 5 0.10
20 5 0.10
20 + 5 + 0.10 but without +