Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line.
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 Ex: If the input is: 0 (or less than 0), the output is: No change. Ex: If the input is 45 the output is: 1 Quarter Dimes 2 Instructor note: Keep in Mind You should have as many larger coins as possible, so if the input is over 100, it should calculate dollar(s) first. You may not use dollar coins on a regular basis, but there is the Sacagawea dollar coin. Keep single vs plural in mind. Usually just an 's" at the end, except for penny versus pennies Think about how you can use the floor division and modulo operators. Only print a coin type if it's part of the solution. For example, if the input is 55, then the output consists of quarters and nickels, but no dimes LAD ACTIVITY 1 money int(input()) 2 3 if money 8: 11 12 13 14 . 2 Quarters 1 Nickel 4.17.1: LAB: Exact change 36 37 38 39 40 print("No change") 45 46 noney money (dollars 180). 47 48 if dollars -- 1: print(dollars, 'Dollar'). 15 16 17 quarters money // 25 18 if quarters and money > 0: 19 20 21 22 23 24 elif dollars 1: print(dollars, 'Dollars') money money (quarters 25) if quarters - 1: print(quarters, 'Quarter') 25 dimes 26 if dines 27 28 29 elif quarters > 1: print(quarters, "Quarters') money // 10 @ and money 0: money money (dines 10) if dines - 1: 30 31 32 33 nickles 34 if nickles 35 print(dimes, 'Dine') elif pennies 1: print(dimes, 'Dines') money // S and money > 8: noney money (nickles 5) if nickles 1: print(nickles, "Nickel') elif pennies 1: 41 pennies- money // 1 42 if pennies and money > 0: 43 44 print(nickles, "Nickles'). noney money (pennies 1) if pennies 1: print (pennies, "Penny") elif pennies 1: print(pennies, 'Pennies'). main.py B/10 Load default template.
Step by Step Solution
★★★★★
3.41 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Function to calculate the fewest coins needed for change def calculatechangecoins amount change Define the coin values in cents coinvalues Dollars 100 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started