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:
According to researchers at Stanford Medical School, the ideal weight for a woman is found by...
/////////////////////////////////////////////////////////////////////////////////// //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 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, 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...