Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Console IO and Arithmetic Expressions The goal of this exercise is to learn more about variables ( page 4 0 ) , named constants (
Console IO and Arithmetic Expressions
The goal of this exercise is to learn more about variables page named constants
page numeric data types page console input using the Scanner class page
and arithmetic expressions page Create a new BlueJ project lab and then create a
class called Conversion in it First edit the comment section at the top to include a brief
description of the program, your name, date, etc.
Body Mass Index BMI is a measure of health based on weight. It can be calculated by
taking your weight in kilograms and dividing it by the square of your height in meters.
Write a program that prompts the user to enter a weight in pounds and height in inches,
and displays the BMI. Note that one pound is kilograms, and one inch is
meters. Define named constants in your program for these decimals.
How to do it:
Import the Scanner class at the top of your program right below the blockcomment
Create a Scanner object named input at the beginning of your main method
Declare two named constants POUNDTOKILOGRAM and INCHTOMETER
Declare three variables of type double named weight, height, and bmi
Add a printlnstatements that will display a header block identifying you, the course,
and the lab number see sample output below This information will appear on the
screen when you run the program. It is used to identify who the output belongs to if
the output is printed separate from the source program.
Prompt for and read in the weight in pounds, and height in inches
Convert the weight to kilogram, and height to meter
Compute the BMI
Display the BMI on the screen with only two digits after the decimal point
Compile and run the program. If it generates the output shown below, copy the output and
paste it inside a block comment at the end of your source program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started