Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each en...Asked by Anonymous
Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each entered amount to a conversion method that displays a breakdown of the passed amount into the fewest bills; in other words, the method calculates the number of 20's, 10's, 5's and 1's as needed
Answers
Answered by
Steve
dollars=1
loop while dollars > 0
bills = breakdown(dollars)
end loop
breakdown(n)
twenties = int(n/20)
n -= twenties
tens = int(n/10)
n -= tens
fives = int(n/5)
n -= fives
ones = n
return(twenties,tens,fives,ones)
loop while dollars > 0
bills = breakdown(dollars)
end loop
breakdown(n)
twenties = int(n/20)
n -= twenties
tens = int(n/10)
n -= tens
fives = int(n/5)
n -= fives
ones = n
return(twenties,tens,fives,ones)
Answered by
Steve
oops. The steps in breakdown should be
n -= twenties*20
and so on for the other bills.
n -= twenties*20
and so on for the other bills.
There are no AI answers yet. The ability to request AI answers is coming soon!