Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Don't know how to do this, looking for where to start
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ylcc23




PostPosted: Tue Mar 29, 2016 10:29 pm   Post subject: Don't know how to do this, looking for where to start

Write a program that makes change for amounts less than one dollar. Input to the program should be a positive integer less than 100, representing an amount of money, in cents. Outputs should be the original amount of money together with a set of coins (quarters, dimes, nickels, cents) that could make up that amount. The program should produce change containing the minimum number of coins required for the given amount. The output should be in a natural, non-stilted form. For example, input of 58 should produce output something like

58 cents: 2 quarters, 1 nickel, and 3 cents.

Rather than

58 cents: 2 quarters, 0 dimes, 1 nickels, 3 cents.

I have a tiny bit so far, but I can't figure out what to do for the rest of it.

amount = int(input("Input an integer between 1 and 99: "))
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed Mar 30, 2016 5:17 pm   Post subject: RE:Don\'t know how to do this, looking for where to start

The div keyword will divide two integers without the remainder or decimal points. So 5 div 2 = 2.

The mod keyword will return the remainder of a division, so 5 mod 2 = 1.

Can you think of a way to use these keywords to complete this assignment?
Srlancelot39




PostPosted: Wed Jul 19, 2017 8:27 am   Post subject: RE:Don\'t know how to do this, looking for where to start

The process is a lot like converting decimal to binary... Smile
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: