This assignment will use the Dialog boxes developed in the book in chapter2 in p
ID: 3695733 • Letter: T
Question
This assignment will use the Dialog boxes developed in the book in chapter2 in pages 99-100 in the code-listing 2-32 (NamesDialog.java) for input and output.Read problem 13 of Chapter4 in page 277. Remember that all your input and output displays are to be in dialog boxes.
A- Remember that all your inputs:
a- height(inches)
b- width (pounds)
are to be done in input dialog boxes.(20 points).
B- Remember that your outputs:
The value of the BMI is to be printed in a output dialog box as seen below in the examples(10 points)
Status of the user: whether "normal weight", or "overweight" or "underweight" is to be printed in an output dialog box as seen below in the examples(10 points).
You are to use an if, else if, else statement similar to the many times used in the book. (60 points).
You are to implement the java class in a file you will call BodyMassIndex.java.
Explanation / Answer
import java.util.Scanner;
public class BodyMassIndex {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
int weight;
int height;
int bMI;
System.out.print ("Enter Your Weight in Pounds: ");
weight = input.nextInt();
System.out.print ("Enter Your Height in Inches: ");
height = input.nextInt();
bMI = (weight * 703) / (height * height);
System.out.printf ("Your Body Mass Index (BMI) is %d ", bMI);
System.out.println ("your BMI status");
System.out.print("Underweight ");
}else if(bMI >= 18.5 && bMI<=24.9 ){
System.out.print("Normal ");
}else if(bMI >= 25 && bMI<=29.9){
System.out.print("Overweight ");
}else if(bMI >=30 ){
System.out.print(" Obese ");
} else {
System.out.print(" wrong information ");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.