Question

In Java Write a program that produces the output shown below. Output Enter your weight in...

In Java Write a program that produces the output shown below.

Output Enter your weight in pounds:200

Enter your height in feet followed by a space then additional inches:5 7

Your BMI is 31.38992486697179 Your risk category is Obese.

Homework Answers

Answer #1
import java.util.Scanner;

public class BMICalculation {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter your weight in pounds: ");
        double weight = in.nextDouble();
        System.out.print("Enter your height in feet followed by a space then additional inches:");
        double height = in.nextDouble() * 12 + in.nextDouble();
        double bmi = (weight * 703) / (height * height);
        String category;
        if (bmi < 18.5) {
            category = "Underweight";
        } else if (bmi < 25) {
            category = "Normal";
        } else if (bmi < 30) {
            category = "Overweight";
        } else {
            category = "Obese";
        }
        System.out.printf("Your BMI is %f Your risk category is %s.\n", bmi, category);
    }
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write code in JAVA Write a program that will output a right triangle based on user...
Write code in JAVA Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char).The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex:If the input...
The formula for calculating BMI is: BMI = (weightInPounds * 703) / (heightInInches * heightInInches) Your...
The formula for calculating BMI is: BMI = (weightInPounds * 703) / (heightInInches * heightInInches) Your application should prompt the user to enter a weight (in pounds) and height (feet first, and then inches). Your application must convert the entered feet and inches to total height in inches, calculate the BMI and display the result with 2 decimal digits. If you used the variable BMI to store the result of you calculation, you can output it with this statement: print("BMI...
B.2. Write a Java program to display a dialog box that asks you to enter your...
B.2. Write a Java program to display a dialog box that asks you to enter your user name and the age as shown below: The program displays in a dialog box the sum of digits of your age. For example, if you age is 19, the sum will be 1+9 = 10 and the output will be as shown below: ( it just shows a message box that says the sum of the digits age of john is 10.
Question 1 Write a program that reads from the user the height and radius of a...
Question 1 Write a program that reads from the user the height and radius of a cylinder, and then outputs the area of this cylinder. The area of the cylinder is calculated using the formula: A=2*π*r*h+2*π*r2, where π = 3.14. Sample run: Enter the radius of the cylinder: 8.2 Enter the height of the cylinder: 9 The area of the cylinder is 885.75 Question 2 Write a program that reads the name, weight and height of a patient. Then the...
Write a modular program that calculates and displays a person’s body mass index (BMI). The BMI...
Write a modular program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula BMI = weight * 703/height2 Where weight is measured in pounds and height is measured in inches. The program should ask the user to enter his or her weight and height and then display the user’s BMI. The...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
Question: Write any java program. Your Program must include loops, decision structures, input and output, comments.
Question: Write any java program. Your Program must include loops, decision structures, input and output, comments.
One estimate for the ideal body weight of a woman is shown below. Use this information...
One estimate for the ideal body weight of a woman is shown below. Use this information to answer parts (A) through (D). 56 kg + 2.4 kg for each inch over 5 feet (A) Find the linear model for an estimate of the ideal weight of a woman using w for ideal body weight (in Kilograms) and h for height over 5 feet (in inches) (B) Interpret the slope of the model (C) If a woman is 5'3 tall, what...
Write a Java program segment (not an entire program) that will summarize the season results for...
Write a Java program segment (not an entire program) that will summarize the season results for 5 players on one of TRU’s basketball teams. Each player played 10 games. Your program segment should ask the user for a player’s name, followed by the points that player scored in each of the 10 games (a total of 11 pieces of input). Your program will then produce the summary line shown below for that player.   Your program should get the data for...
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++