Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ratios

 
Arthur Zadrozny
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have two numbers, 447 which represnts lets say apples, and 921 which represents oranges, how can I write the ratio of the number of apples to the number of oranges? Thanks.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arthur Z,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried or thought to try so far? Why did you do that? What did it do? What did you expect it to do?
Feel free to post code examples. When doing so, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try System.out.println("447 / 921 apples per orange");
There are also more general possibilities:

We can also do fractional numbers with decimal pips if you need them.
-Barry
 
Neil Laurance
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Often ratios are displayed as n:1 or 1:n

Cheers, Neil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic