Menu

[Solved] Explain Line Code Public Class Bmi Private String Name Private Int Age Private Double Weig Q37286070

explain what each line of code does

————————————————————-

public class BMI { private String name; private int age; private double weight; private double inches; public BMI(String name, int age, double weight, double inches) { this.name = name; this.age = age; this.weight = weight; this.inches = inches; } public String getName() { return name; } public double getBMI() { return (weight / (inches * inches)) * 703; } public String getStatus() { double bmi = getBMI(); String category; if(bmi <= 18.5) { category = “Underweight”; } else if(bmi < 25) { category = “Normal weight”; } else if(bmi < 30) { category = “Overweight”; } else { category = “Obese”; } return category; }}import java.util.Scanner;public class BMICalculation { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print(“Enter your name: “); String name = in.nextLine(); System.out.print(“Enter your age: “); int age = in.nextInt(); System.out.print(“Enter your weight in pounds: “); int weight = in.nextInt(); System.out.print(“Enter your height in inches: “); double feet = in.nextDouble(); BMI bmi = new BMI(name, age, weight, feet); System.out.printf(“The BMI for %s is %.2f: %sn”, bmi.getName(), bmi.getBMI(), bmi.getStatus()); }}

Expert Answer


Answer to explain what each line of code does ————————————————————- public class BMI { pri… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *