0

I need help on why this is happening:

I'm currently doing the cash problem. I used get_float to get user's amount and then used round(amount_from_user * 100) to convert the float to int (i.e cent) as per the problem spec.

Here's the problem If user enters a float e.g 0.02 the program round off the value and then execute a loop to count how many times each coin is given to the user (in this ex. program will print out the value 2 (no of coin cust. is given). [AS EXPECTED]

But If user enters an int e.g 2 or 2.0 or 2 00, etc INSTEAD of a float,, the program will do value_in_int (e.g 2.00) * 100 = 200 and then starts counting the no of times each coin is given to Cust. Which will equal 8 and not 2 [NOT EXPECTED RESULT]

1 Answer 1

0

The assignment is to give the total amount entered by user in coin. Not just the cents. So 2 (or 2.0 or 2.00) ie. 2 dollars, should return 8. Change would be 8 quarters.

1
  • Thanks, now I'm cleared and I have submitted the problem Commented Dec 21, 2019 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .