• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Logical Operators

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the example and the link they were very helpful.
 
Marshal
Posts: 76862
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic