Question: Java program for BMI calculator using Access Modifiers (e.g. private and public) for the below following code. import java.util.Scanner; class BMI { public static void

Java program for BMI calculator using Access Modifiers (e.g. private and public) for the below following code.

import java.util.Scanner;

class BMI { public static void main(String[] args) {

Scanner input = new Scanner(System.in); // Declare variables double height, weight; System.out.println("Enter weight in pounds:"); weight = input.nextDouble(); weight *= 0.45359237; System.out.println("Enter height in inches:"); height = input.nextDouble(); height *= 0.0254;

double BMI = (weight / (height * height)); System.out.println("The BMI is " + String.format("%.2f", BMI));

// Calculate the category as per the BMI of the person and print the interpretation if (BMI < 18.5){ System.out.println("Underweight"); } else if(BMI >= 18.5 && BMI <25.0){ System.out.println("Normal"); } else if(BMI >= 25.0 && BMI <30.0){ System.out.println("Overweight"); } else{ System.out.println("Obese"); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!