File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to identify the whole number in code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to identify the whole number in code" Watch "How to identify the whole number in code" New topic
Author

How to identify the whole number in code

Rizwan Patel
Ranch Hand

Joined: Jan 03, 2008
Posts: 59
Hi All,

Please look into this problem

Scenario starts ......,
1.I have x (dollar) amount, I have been allowed to give constant value say 8(dollar) to each of kid to spend.
2. I have to find out to how many kid I can distribute this amount say (x/8)
For this I found out that If this division is not whole number then roundin up the value
3. Now I get the number of Kids can receive the amount portion say "numKids"
4. Now the another problem : How much can a kid get so I decided to distribute like this :
Total amount : x
Total Kids : numKids
So each kid wil get x/numKids)dollar only when this results in "Whole Number"
If "Division of amount" is not whole number then I have set the rule that The youngest kid get an additional 1 dollar. and all other remaining kids will get the equal part.

Scenario completes...

Please help me in implementation of finding out "Whole Number"?

Thanks in advance.Waiting more eagerly for your response


scjp 1.5, OCPJWSD 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35249
    
    7
Are you familiar with the "modulo" function? It tells you the remainder of an integer division. To see it in action, write a program that calculates "x % numKids".


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to identify the whole number in code
 
Similar Threads
Array problem
Question on sum of syracuse sequence (memorization question)
help for a newbie that's out of her depth!
almost there!
Idempotent methods