Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(JAVA) Write a Java program that calculates the Body Mass Index (BMI) for the user. The user must type in her height in centimeters and

(JAVA)

Write a Java program that calculates the Body Mass Index (BMI) for the user. The user must type in her height in centimeters and weight in kilograms, and the computer prints out the user's BMI.

Calculate the BMI using the following formula:

 w BMI = ____________________ (h / 100 ) * (h / 100) 

where w is weight in kilograms and h is height in centimeters.

Use the Java standard class Scanner to get user input and System.out.println() to show the results to the user. You must read the input into int variables in your program.

Start out - with pencil and paper - by listing the inputs you need from the user and the output(s) your program will generate. Next, calculate your own body mass index by hand; between 20 and 25 is considered normal. Use your own data as one of the test cases when you test your program. Write the algorithm for the whole program in English on paper, and then translate to Java line by line. Your variables for height and weight must be int, but your result is in double.

When you are ready to submit, use the number 162 for the input height in centimeters, and use the number 67 for the input weight in kilograms. The output for this test should contain 25.5. Don't prompt the user for these values, just type these values into the box labelled "Pre-enter any input", and read them into your program using the Scanner.

In order to receive full credit, your program must:

-contain a well-written comment at the top that tells what the program does.

-not break up the calculation into separate statements.

-not flip the fraction, use the formula exactly as given.

Follow the specifications above EXACTLY. If you have questions, ask in our Canvas Discussion forum. Read user input into int variables, but perform your calculations using double.

Note that after you submit your program here in the zyLab, your instructor will perform a code review to make sure that it fully satisfies these requirements and the Program Guidelines found in Canvas Module Week 2. You will receive additional points (or not) depending on the results of that review.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions