Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logical Operators

 
Debo Prez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Check conditional operators on this page for more details.


[MODERATOR ACTION: Removed full code solution]
Kemal Sokolovic, please remember this site is NotACodeMill(←click).
 
Debo Prez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the example and the link they were very helpful.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic