This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Comparison expresions

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so i have a range to compare and i am havning a hard time figuring out the code.


if the variable is
less than 18.5 then print Underweight
between 18.5 and 24.9 then print Normal
between 25 and 29.9 then print Overweight
30 or greater then print Obese

here is my code sofar


if(Num == 1){
System.out.print( "Enter Your wieght: " ); // prompt
weightLb = input.nextInt(); // read first number from user


System.out.print( "Enter Your hight: " ); // prompt
hightIn = input.nextInt(); // read second number from user

bmiS = (weightLb * 703)/(hightIn*hightIn); // body Mass Index in standared

if ( bmiS <= 18.4 ){
System.out.printf( "%s, %d, %s, which means your Underweight.", "Your BMI value is", bmiS );
}
if ( bmiS >= 30 ){
System.out.printf( "%s, %d, %s, which means your Obese.", "Your BMI value is", bmiS );
}
if ( bmiS < 24.9, bmiS > 18.5 ){
System.out.printf( "%s, %d, %s, which means your Normal.", "Your BMI value is", bmiS );
}
if ( bmis < 29.9, bmiS > 25){
System.out.printf( "%s, %d, %s, which means your Overweight.", "Your BMI value is", bmiS );
}
}
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Nathan, welcome aboard...

First... i'm so confuse what's the point of your topic...
Seem you need the code for your matter... But Nathan,here you can't ask someone to make code for you.. We are here to find and discuss the best solution for people question.. We will guide you if we know..



Here the sample.. if you hard to figure it out.. just ask which part makes you confuse..
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nathan Mansmith wrote:so i have a range to compare and i am having a hard time figuring out the code.




Hi Nathan,

Welcome to JavaRanch where exactly you are having a difficulty? The code you posted seems to be okay. I guess you have to complete it.

But what is the



for? What sort of comparison you are doing there?
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ramses Butarbutar wrote: But Nathan,here you can't ask someone to make code for you.. We are here to find and discuss the best solution for people question.. We will guide you if we know..



Having said the same, you had contradicted?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raghavan Muthu wrote:The code you posted seems to be okay.


Really? I didn't think so.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:
Really? I didn't think so.



I meant to say, the pseudo code for the piece of his requirement. I did NOT mean the complete program.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic