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.
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
• Number of slices to send:
Optional 'thank-you' note:
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
• Number of slices to send:
Optional 'thank-you' note:
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
• Number of slices to send:
Optional 'thank-you' note:

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
• Number of slices to send:
Optional 'thank-you' note:

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..

Author
Posts: 12617
• Number of slices to send:
Optional 'thank-you' note:

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

Really? I didn't think so.

Raghavan Muthu
Ranch Hand
Posts: 3389
• Number of slices to send:
Optional 'thank-you' note:

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.