Jump to content

Help with a problem, started learning

- - - - -

  • Please log in to reply
3 replies to this topic

#1
rgmartino

rgmartino

    Newbie

  • Members
  • Pip
  • 1 posts
So basically they are asking me to write a program that calculates the number of bills of 100, 50, 20, 10, 5 to breakdown a quantity entered. But calculates the least quantity of bills of each type to make the quantity entered.

Any help appreciated.

#2
geralddevera

geralddevera

    Newbie

  • Members
  • Pip
  • 1 posts
Before I proceed, I would like to thank everyone who greeted me this day. Very well-appreciated. :)

To Mr. rgmartino:

You can visit my site spammy link deleted

You can learn from it, at the same time, you could build your own understanding from the simple tutorials I've made from it.

Happy Coding! :D

Edited by WingedPanther, 04 August 2011 - 07:55 AM.
delete spammy link


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
@geralddevera: how about helping the op?

@rgmartino: you will probably want to use the / and % operators to do this. Is it going to be in C or C++?
Also, do you know how to break down $87 by hand?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US

Quote

do you know how to break down $87 by hand?
Yeah, knowing how to do a task is part of making a program do that task.

Let's say the number is 126.

(integer) 126 / 100 = 1
so it's 1 times $100.

126 % 100 = 126 - (126 / 100 * 100) = 126 - (1 * 100) = 126 - 100 = 26

26 / 50 = 0
so it's 0 times $50.

26 % 50 = 26

26 / 20 = 1
so it's 1 times $20.

26 % 20 = 6

6 / 10 = 0
so it's 0 times $10.

6 % 10 = 6

6 / 5 = 1
so it's 1 times $5.

6 % 5 = 1
then we have $1 left over.

So the answer would be one $100 bill, one $20 bill, one $5 bill, and remaining $1. That's sort of the idea, I think.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users