Question

According to researchers at Stanford Medical School, the ideal weight for a woman is found by multiplying her height in inches by 3.5 and subtracting 108. The ideal weight for a man is found by multiplying his height in inches by 4 and subtracting 128. Write a Java program that asks the user for his/her gender, height and weight and responds with the message You are underweight or You are overweight. 4.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

JAVA PROGRAM:


import java.util.Scanner;
public class WeightCheck
{
Double weight;
Double height;
WeightCheck(Double weight,Double height)
{
this.weight=weight;
this.height=height;

}
public Double getWeight()
{
return weight;
}
public Double getHeight()
{
return height;
}
public static void main(String[] args) {
Scanner ss=new Scanner(System.in);
System.out.println("Enter gender m or f");
String gender=ss.nextLine();
System.out.println("Enter your Height (in inches)");
Double myHeight=ss.nextDouble();
System.out.println("Enter your Weight (in kg)");
Double myWeight=ss.nextDouble();
WeightCheck wc=new WeightCheck(myWeight, myHeight);
Double idealWeightForMale=wc.getHeight()*4-128;
Double idealWeightForFemale=wc.getHeight()*3.5-108;
System.out.println("Your Gender : "+gender);
System.out.println("Your Height : "+wc.getHeight()+" inches");
System.out.println("Your Weight : "+wc.getWeight()+" kg");
if(gender.equals("m")){

if(idealWeightForMale > wc.getWeight())
{
System.out.println("Remark : you are underweight,your ideal weight should be "+ idealWeightForMale+" kg");
}
else if(idealWeightForMale < wc.getWeight())
{
System.out.println("Remark : you are overweight,your ideal weight should be "+ idealWeightForMale+" kg");
}
else
System.out.println("Remark : your height to weight ratio is good "+ idealWeightForMale+" kg");

}
else
{

if(idealWeightForFemale > wc.getWeight())
{
System.out.println("Remark : you are underweight,your ideal weight should be "+ idealWeightForFemale+" kg");
}
else if(idealWeightForMale < wc.getWeight())
{
System.out.println("Remark : you are overweight,your ideal weight should be "+ idealWeightForFemale+" kg");
}
else
System.out.println("Remark : your height to weight ratio is good" + idealWeightForFemale+" kg");
}
}
}
OUTPUT:

Enter gender m or f Enter your Height (in inches) Enter your Weight (in kg) 64 Your Gender f Your Height 5.0 inches Your Weight 64.0 kg Remark you are overweight,your ideal weight should be -90.5 kg

Add a comment
Know the answer?
Add Answer to:
According to researchers at Stanford Medical School, the ideal weight for a woman is found by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

    /////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates the user's body-mass-index (BMI) // 3. and then prints an appropriate message based on the user's BMI /////////////////////////////////////////////////////////////////////////////////// #include <iostream> using namespace std; void printWelcome(); // ask the weight (in pounds) and height (in inches) of the user and store the values in formal // parameters weight and height, respectively void getWeightAndHeight(float& weight, float& height); // calculate and return the BMI (Body-Mass-Index) based on...

  • Having trouble with the do while/while loop and the switch statement. I got some of the...

    Having trouble with the do while/while loop and the switch statement. I got some of the switch statement but cant get the program to repeat itself like it should.What i have so far for my code is below. Any help is appreciated... i am not sure what I am doing wrong or what i am missing. I am completely lost on the while loop and where and how to use it in this scenario. import java.util.Scanner; public class sampleforchegg {...

  • Lindsay Smyth, a 15 year old young woman, was admitted by her pediatrician for evaluation. Her parents, who are divorced...

    Lindsay Smyth, a 15 year old young woman, was admitted by her pediatrician for evaluation. Her parents, who are divorced, came with her to the hospital. The client lives with her mother and has no siblings. She has no past psychiatric history or other medical problems. Her pediatrician and her parents report that the client has lost 40lbs in the past year. Despite this weight loss, she has continued to go to school and to excel academically. She also jogs...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT