A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields 3 fives and 4 ones. Write a single statement that assigns the number of one dollar bills to variable numOnes, given

Respuesta :

Answer:

Written in Python:

dollars = int(input("Amount: "))

numFive = int(dollars/5)

numOnes = dollars%5

print(str(dollars)+" yields "+str(numFive)+" fives and "+str(numOnes)+" ones.")

Explanation:

This line prompts user for input

dollars = int(input("Amount: "))

This line calculates the number of 5 that can be gotten from the input. This is done using integer division

numFive = int(dollars/5)

This line gets the remaining ones. This is done by using the modulo sign to get the remainder when input is divided by 5

numOnes = dollars%5

This line prints the required output

print(str(dollars)+" yields "+str(numFive)+" fives and "+str(numOnes)+" ones.")