subject

Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. If input is 0 or less, output is 'No Change'
For Example: Input: 45
Output:
1 Quarter
2 Dimes
input_val = int(input())
if input_val <= 0:
print('No change')
else:
num_dollars == input_val // 100
input_val %= 100
num_quarters == input_val // 25
input_val %= 25
num_dimes == input_val // 10
input_val %= 10
num_nickels == input_val // 5
input_val %= 5
num_pennies == input_val
if num_dollars > 1:
print('%d dollars' % num_dollars)
elif num_dollars ==1:
print('%d dollar' % num_dollars)
if num_quarters > 1:
print('%d quarters' % num_quarters)
elif num_quarters ==1:
print('%d quarter' % num_quarters)
if num_dimes >1:
print('%d dimes' % num_dimes)
elif num_dimes ==1:
print('%d dime' % num_dimes)
if num_nickels >1:
print('%d nickels' % num_nickels)
elif num_nickels ==1:
print('%d nickel' % num_nickels)
if num_pennies >1:
print('%d pennies' % num_pennies)
elif num_pennies ==1:
print('%d penny' % num_pennies)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:50
The file sales data.xlsx contains monthly sales amounts for 40 sales regions. write a sub that uses a for loop to color the interior of every other row (rows 3, 5, etc.) gray. color only the data area, columns a to m. (check the file colors in excel.xlsm to find a nice color of gray.)
Answers: 2
question
Computers and Technology, 23.06.2019 01:50
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors.java.
Answers: 2
question
Computers and Technology, 23.06.2019 11:30
In cell h5 enter a formula that will calculate the percentage of attendees that went to the altamonte springs job fair in 2018.
Answers: 1
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
You know the right answer?
Write a program with total change amount as an integer input, and output the change using the fewest...
Questions
question
Chemistry, 16.02.2021 16:50
question
Spanish, 16.02.2021 16:50
question
Mathematics, 16.02.2021 16:50
question
Mathematics, 16.02.2021 16:50
question
Mathematics, 16.02.2021 16:50
question
Physics, 16.02.2021 16:50
Questions on the website: 13722362