The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Python


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-10-2007, 05:19 PM
icemaster1500
Posts: n/a
[SOLVED] Need help with a Python programming assignment?

hello, to any1 familar with python programing, I'm to do this assigment for comp sci 30, i've been trying for a week still can't get it to run, the assignmet is:

1. Write a program that calculates the number of quarters, dimes, nickels and pennies necessary to generate the number of cents entered as input.

For example, if 93 cents is entered as the input, then the program should indicate that 3 quarters, 1 dime, 1 nickel and 3 pennies are necessary to add up to 93 cents.

i've been given the resource http://www.ibiblio.org/obp/thinkCSpy/
as well as http://rgruet.free.fr/PQR24/PQR2.4.html

the first link is better, can any1 help me, i've managed to get it to work with that def thing but it doesn't save the change value, can any1 help me do something similar? the teacher hinted me, that it was something to do with one while statement, and o buch of other different kinds statements working under it

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 06-10-2007, 05:20 PM
bluedoggy2006
Posts: n/a
int cents = 93

int quarters = (cents - cents%25)/25
cents -= 25*quarters

int dimes = (cents - cents%10)/10
cents -= 10 * dimes

int nickels = (cents - cents%5)/5
cents -= 5 * nickels

This formula (cents - cents%25)/25 is

(cents - the remainder of cents after 25 is divided into it)

Now your left with a number 25 can divide into evenly and then you can divide 75 cents by 25 cents to get the amount of quarters.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Closed Thread


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:57 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50