Question

(In Python 3) Write a program with total change amount as an integer input, and output...

(In Python 3)

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
2 Dimes 

So far, I have:

change_input = int(input())

if change_input <= 0:
print("No Change")
else:
dollars = total // 100
total %= 100
quarters = total // 25
total %= 25
dimes = total // 10
total %= 10
nickels = total // 5
total %= 5
pennies = total
if dollars > 1:
print('%d Dollars' % dollars)
elif dollars == 1:
print('%d Dollar' % dollars)

if quarters > 1:
print('%d Quarters' % quarters)
elif quarters == 1:
print('%d Quarter' % quarters)

if dimes > 1:
print('%d Dimes' % dimes)
elif dimes == 1:
print('%d Dime' % dimes)

if nickels > 1:
print('%d Nickels' % nickels)
elif nickels == 1:
print('%d Nickel' % nickels)

if pennies > 1:
print('%d Pennies' % pennies)
elif pennies == 1:
print('%d Penny' % pennies)

But I can't get an output with the fewest amount of coins.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note : plz follow the space indentation exactly as per in the program screenshot.So that u wont get any errors.

Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

===================================

# Declaring variables
dollars=0
quarters=0
dimes=0
nickels=0
pennies=0
total=0

# Getting the input entered by the user
total = int(input())

# if the input is 0 or less than 0 "Display No Change"
if total <= 0:
print("No Change")
else:
dollars = total // 100
total %= 100
quarters = total // 25
total %= 25
dimes = total // 10
total %= 10
nickels = total // 5
total %= 5
pennies = total
  
if dollars >0:
print('%d Dollars' %dollars)
if quarters >0:
print('%d Quarters' %quarters)
if dimes > 0:
print('%d Dimes' %dimes)
if nickels > 0:
print('%d Nickels' %nickels)
if pennies > 0:
print('%d Pennies' %pennies)


==============================

Output:

===========================

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
(In Python 3) Write a program with total change amount as an integer input, and output...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program with total change amount as an integer input, and output the change using...

    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 the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes

  • I have this code for python: num = int(input()) if num == 0: print('No change') else:...

    I have this code for python: num = int(input()) if num == 0: print('No change') else: dol = num // 100 num %= 100 Quarters = num // 25 num %= 25 Dimes = num // 10 num %= 10 Nickels = num // 5 num %= 5 Pennies = num if dol > 0: if dol == 1: print('1 Dollar') if Dollars > 1: print(dol,'Dollars') if Quarters > 0: if Quarters == 1: print('1 Quarter') if Quarters > 1:...

  • Develop a solution that would return the fewest coins in change from a purchase of under one doll...

    this activity It must be done Flowchart PAC and IPO Develop a solution that would return the fewest coins in change from a purchase of under one dollar. (Incude pennies, nickels, dimes, quarters, and half dollars.) Example: purchase 63 change 370 I quarter 1 dime coins 2 pennies Develop a solution that would return the fewest coins in change from a purchase of under one dollar. (Incude pennies, nickels, dimes, quarters, and half dollars.) Example: purchase 63 change 370 I...

  • I need to change this python program into one that counts back the LEAST AMOUNT OF...

    I need to change this python program into one that counts back the LEAST AMOUNT OF COINS. Ex: if i input 44 as my change, how can i make it show 4 dimes and 4 pennies instead of 1 quarter, a dime, and 9 pennies? heres my code so far in PYTHON " cents=int(input("Please enter the change in Cents: ")) Quarter= int(cents/25)#25cents=1 Quarter Dime =int (cents%25/10)# 10 cents=1 Dime cents =(cents%25)%10 print(Quarter,"quarters",Dime,"dimes and",cents,"cents") "

  • in c++ please tortViewHistory Bookmarks Window Help learn Tybooks.com 3.12. LAB: Exact change functions My Ibrary...

    in c++ please tortViewHistory Bookmarks Window Help learn Tybooks.com 3.12. LAB: Exact change functions My Ibrary > CS 010: Introduction To Computer Science for Science, Mathematics & Engin. 8.12: LAB: Exact change - functions zyBooks catalog Help/FAQ Stephanie R Write a program with total change amount as an integer input that outputs 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...

  • in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949)...

    in c code x Global Soccer 1.docx x Acceleration Due to 6 x M Inbox (5,949) - joshfor x M Inbox (4,224) - joshuar X ® AC ads/ACFrOgA6UB 1k4Z1i1xGLNQ1Lntj510 lutEUaA..pdf ECE 175: Computer Programming for Engineering Applications Lab Assignment #2 (Thursday sessions) Relevant Programming Concepts: • Branch Structure • Loop Problem 1 (15 points): Develop a C program that asks a user to enter a total change amount in cents) and outputs the change using the fewest coins. The coin...

  • it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dolla...

    it c++ coding. please write on atom software. 1. Write a program that converts dollars into coins a. Request a dollar amount as an integer: $5.34 is input as 534 b. Use a constant variable to represent each coin as a fixed value: const int NICKEL 5; c. Use division and the mod function to calculate the number of each coin. Change Calculator Enter dollar amount (as an integer): $534 The equivalent in coins: 21 Quarters 0 Dimes 1 Nickels...

  • C++ HW Question Your program will simulate a simple change maker for a vending machine. It...

    C++ HW Question Your program will simulate a simple change maker for a vending machine. It will start with a stock of coins and dollars. It will then repeatedly request the price for an item to be purchased or to quit. If given a price, it will accept nickels, dimes, quarters, one-dollar and five-dollar bills—deposited one at a time—in payment. When the user has deposited enough to cover the cost of the item, the program will calculate the coins to...

  • Write a C program that calculates exact change. In order to receive full credit, please remember...

    Write a C program that calculates exact change. In order to receive full credit, please remember that only int arithmetic is exact, so you’ll need to break up your double into two ints, the one before the decimal point and the one after the decimal point. Another point worth mentioning is that the % operator gives the remainder. In other words, when working with int values, 9 / 5 = 1 whereas 9 % 5 = 4. Keep this in...

  • Write a program called CountCoins.java that prompts the user for the input file name (you can...

    Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT