File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Ratios Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Ratios" Watch "Ratios" New topic


Arthur Zadrozny

Joined: Sep 19, 2002
Posts: 3
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

Joined: Dec 10, 2001
Posts: 7023
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!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
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

Joined: Aug 03, 2002
Posts: 7729
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.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Neil Laurance
Ranch Hand

Joined: Jul 18, 2002
Posts: 183
Often ratios are displayed as n:1 or 1:n

Cheers, Neil
I agree. Here's the link:
subject: Ratios
It's not a secret anymore!