• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to identify the whole number in code

 
Ranch Hand
Posts: 59
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
reply
    Bookmark Topic Watch Topic
  • New Topic