Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NEED HELP with assignment In this assignment you will re-create the java program

ID: 3670961 • Letter: N

Question

NEED HELP with assignment

In this assignment you will re-create the java program that calculates the body mass index (BMI) based on the users height and weight using Java Swing Components. Below are the steps to complete the assignment.

Create a new java application using Netbeans IDE named "BMI_Calculator".

The program should allow the user to input their name, height, and weight.

Next add a submit button to the page that will calculate the bmi and display it on the page when the button is pressed.

Using the height and weight the program should calculate the bmi using the following equation 703 * weight/height2

Based on the following chart print the user's weight status to the screen.

BMI Chart

BMI Weight Status Below 18.5 Underweight 18.5 - 24.9 Normal 25.0 - 29.9 Overweight 30.0 and Above Obese

Explanation / Answer

public class UsePersonBMI {

public static void main(String[] args) {

Person person1 = new Person("Mary Jane", 45, 160, 67);

System.out.println("The BMI for " + person1.getName() + " is "

+ person1.getBMI() + " " + person1.getStatus());

Person person2 = new Person("Peter Parker", 170, 71);

System.out.println("The BMI for " + person2.getName() + " is "

+ person2.getBMI() + " " + person2.getStatus());

}

}

public class Person {

private String name;

private int age;

private double weight; // in pounds

private double height; // in inches

public final double KILOGRAMS_PER_POUND = 0.45359237;

public final double METERS_PER_INCH = 0.0254;

public Person(String name, int age, double weight, double height) {

this.name = name;

this.age = age;

this.weight = weight;

this.height = height;

}

public Person(String name, double weight, double height) {

this(name, 25, weight, height);

}

public double getBMI() {

double bmi = weight * KILOGRAMS_PER_POUND /

((height * METERS_PER_INCH) * (height * METERS_PER_INCH));

return Math.round(bmi * 100) / 100.0;

}

public String getStatus() {

double bmi = getBMI();

if (bmi < 16)

return "seriously underweight";

else if (bmi < 18)

return "underweight";

else if (bmi < 24)

return "normal weight";

else if (bmi < 29)

return "over weight";

else if (bmi < 35)

return "seriously over weight";

else

return "gravely over weight";

}

public String getName() {

return name;

}

public int getAge() {

return age;

}

public double getWeight() {

return weight;

}

public double getHeight() {

return height;

}

}