Knowee
Questions
Features
Study Tools

Star Fitness Club wants to calculate the Body Mass Index (BMI) for all its customers. Customers may enter their height and weight. Each customer should know their body mass index and weight loss or gain goals to be fit and healthy. Help them to achieve this with the help of a Java program. The formula for calculating BMI is weight/((height/100) *(height/100)).Display the bmi with respect to 2 decimal points.If bmi is greater than or equal to 25, print "You are overweight" and then print the number of kilograms to be reduced to become fit as "Reduce <<kgs>>kg to be fit".If bmi is less than 25 and greater than or equal to 18.5, print "You are fit and healthy".If bmi is less than 18.5, print "You are underweight" and then print the number of kilograms to be gained to become fit as "Gain <<kgs>>kg to be fit".Note:In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.Ensure to follow the object-oriented specifications provided in the question description.Ensure to provide the names for classes, attributes, and methods as specified in the question description.Adhere to the code template, if provided.Please do not use System.exit(0) to terminate the program. Sample Input 1:Enter weight in kg108Enter height in cm168Sample Output 1:Your BMI is 38.27. You are overweightReduce 13.27 kg to be fitSample Input 2:Enter weight in kg68Enter height in cm172Sample Output 2:Your BMI is 22.99. You are fit and healthySample Input 3:Enter weight in kg42.7Enter height in cm158Sample Output 3:Your BMI is 17.10. You are underweightGain 1.40 kg to be fit

Question

Star Fitness Club wants to calculate the Body Mass Index (BMI) for all its customers. Customers may enter their height and weight. Each customer should know their body mass index and weight loss or gain goals to be fit and healthy. Help them to achieve this with the help of a Java program. The formula for calculating BMI is weight/((height/100) *(height/100)).Display the bmi with respect to 2 decimal points.If bmi is greater than or equal to 25, print "You are overweight" and then print the number of kilograms to be reduced to become fit as "Reduce <<kgs>>kg to be fit".If bmi is less than 25 and greater than or equal to 18.5, print "You are fit and healthy".If bmi is less than 18.5, print "You are underweight" and then print the number of kilograms to be gained to become fit as "Gain <<kgs>>kg to be fit".Note:In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given by the user, and the rest of the text represents the output.Ensure to follow the object-oriented specifications provided in the question description.Ensure to provide the names for classes, attributes, and methods as specified in the question description.Adhere to the code template, if provided.Please do not use System.exit(0) to terminate the program. Sample Input 1:Enter weight in kg108Enter height in cm168Sample Output 1:Your BMI is 38.27. You are overweightReduce 13.27 kg to be fitSample Input 2:Enter weight in kg68Enter height in cm172Sample Output 2:Your BMI is 22.99. You are fit and healthySample Input 3:Enter weight in kg42.7Enter height in cm158Sample Output 3:Your BMI is 17.10. You are underweightGain 1.40 kg to be fit

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a step-by-step guide to creating a Java program that calculates the Body Mass Index (BMI) for customers of Star Fitness Club:

  1. First, create a class named Customer:
public class Customer {
    private double weight;
    private double height;
    //...
}
  1. Inside the Customer class, create two private instance variables weight and height of type double.

  2. Create a constructor for the Customer class that takes two parameters for weight and height:

public Customer(double weight, double height) {
    this.weight = weight;
    this.height = height;
}
  1. Create a method calculateBMI that calculates the BMI using the formula weight/((height/100) *(height/100)):
public double calculateBMI() {
    return weight / ((height / 100) * (height / 100));
}
  1. Create a method getFitnessStatus that returns a String indicating the fitness status of the customer based on their BMI:
public String getFitnessStatus() {
    double bmi = calculateBMI();
    if (bmi >= 25) {
        return "You are overweight. Reduce " + (bmi - 25) + " kg to be fit.";
    } else if (bmi >= 18.5) {
        return "You are fit and healthy.";
    } else {
        return "You are underweight. Gain " + (18.5 - bmi) + " kg to be fit.";
    }
}
  1. Now, create a main method to get the input from the user and display the output:
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("Enter weight in kg");
    double weight = scanner.nextDouble();
    System.out.println("Enter height in cm");
    double height = scanner.nextDouble();
    Customer customer = new Customer(weight, height);
    System.out.printf("Your BMI is %.2f. %s\n", customer.calculateBMI(), customer.getFitnessStatus());
}

This program will calculate the BMI of a customer and print their fitness status based on the BMI.

This problem has been solved

Similar Questions

John is a fitness trainer and needs to calculate the Body Mass Index (BMI) for his clients to assess their health status. Write a program for him that takes the weight in kilograms and height in meters of a client as input, calculates their BMI, and determines if they fall within the healthy range.Note: The healthy range of BMI is 18.5 to 24.9 (both inclusive).Input format :The input consists of two double values: the weight in kilograms and the height in meters.Output format :The first line of output prints "BMI: X" where X is a double value, rounded off to two decimal places.The second line prints one of the following:If the BMI is within the valid range, print "Healthy Range".Otherwise, print "Not in Healthy Range".Refer to the sample output for formatting specificationsCode constraints :10.0 ≤ weight ≤ 300.00.00 ≤ height ≤ 3.00Sample test cases :Input 1 :65.81.75Output 1 :BMI: 21.49Healthy RangeInput 2 :124.31.87Output 2 :BMI: 35.55Not in Healthy Range

Problem StatementBalaji wants your help to design a fitness calculator. The simple measure of body fitness is the BMI or Body Mass Index. It depends only on the height L and weight W of a person. It is defined as BMI = [weight / height2] where weight is taken in kilograms and length in meters. Four general grades are proposed:Underweight[U] - when BMI < 18.5Normal weight[N] - 18.5 <= BMI < 25.0Heavyweight [H] - 25.0 <= BMI < 30.0Overweight [O] - above or equal to 30.0Write a program that takes in the Weight (in Kg) and Length (in meters) of an individual and displays the grade as U, N, H, O.Note: Store all the variables in register memory.Input format :The first line of input consists of an integer, representing the weight.The second line consists of a double value, representing the height in meters.Output format :The output displays the grade based on the given conditions.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases will fall under the following constraints:60 ≤ weight ≤ 2001.0 ≤ height ≤ 5.0Sample test cases :Input 1 :1303.5Output 1 :UInput 2 :2002.7Output 2 :HInput 3 :902.1Output 3 :NInput 4 :741.3Output 4 :O

BMI CalculatorCreate an application which calculates BMI (Body Mass Index)Your app should have 2 input boxesTake weight in kgs from userTake height in meters from userBased on entered height and weight calculate BMI of that personHere is the formula for manually calculating BMI BMI = (weight) / (height * height)From the obtained BMI result, display whether the person isUnderWeight - bmi <= 18.4Normal Weight - bmi >= 18.5 && bmi <= 24.9Overweight - bmi >= 25 && bmi <= 29.9Obese - bmi >= 30Hint: use If conditionsSample Output

The Body Mass Index (BMI) is the ratio of the weight of a person(in kilograms) to the square of the height(in meters)Formula To Calculate Body Mass Index (BMI)BMI = weight / (height x height);Write a JavaScript program that calculates the BMI, and reports the BMI category as per the following table:BMI Category BMIUnderweight below 18.5Healthy 18.6 to 24.9Overweight 25 to 25.9Obese Obese 30 or greaterInput Data

Given height and weight of a person in float, calculate Body Mass index of the person and print respective output based on calculation. Formulae for calculation: [weight (kg) / height (cm) / height (cm)] x 10,000 .For Example: weight =76.7 , height=162.2 BMI=((76.7/162.2)/162.2)X 10,000BMI=(0.4728/162.2)X 10,000 BMI=0.000291X 10,000 BMI=29.1 So, it is Overweight.Print "Underweight" or "Healthy weight" or "Overweight" or "Obesity". Below 18.5        Underweight 18.5 – 24.9        Healthy weight 25.0 – 29.9       Overweight 30.0 and Above      ObesityInput Format:Accept two inputs, weight(float) and height(float)Output Format:Print "Underweight" or "Healthyweight" or "Overweight" or "Obesity"Constraints:1<=N<=10^15Sample Input 1:46.5 165.3Sample Output 1:UnderweightSample Input 2:76.7 162.2Sample Output 2:Overweight

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.