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 Logical Operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Logical Operators" Watch "Logical Operators" New topic

Logical Operators

Debo Prez

Joined: Sep 23, 2012
Posts: 3
I'm very new to Java and we have an assignment I can't figure out. If I can get some feedback or help on how to do it, it would be much appreciated. Thank you!

I am asked to modify this code to have float variables (which I have done) then I am to add a second pair of float variables, and include logical operators &&, and || to print out the results if both comparisons are true or either are true.

[Added code tags - see UseCodeTags for details]
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

So, what particular problems are you having?

Have you studied up on the && and || operators?

Can you come up with a sentence in English that tests whether both/either comparisons are true?

Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Check conditional operators on this page for more details.

[MODERATOR ACTION: Removed full code solution]
Kemal Sokolovic, please remember this site is NotACodeMill(←click).

The quieter you are, the more you are able to hear.
Debo Prez

Joined: Sep 23, 2012
Posts: 3
Thank you for the example and the link they were very helpful.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46335
Welcome to the Ranch

Why are you using floats? They should be reserved for instances where one can specifically cope with their imprecision. For example in colours, where you can use floats between 0.0f and 1.0f inclusive, but there are actually 256 different values in that range.
I agree. Here's the link:
subject: Logical Operators
It's not a secret anymore!