Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class BMI
- {
- public static void main(String args[])
- {
- Scanner pikachu = new Scanner(System.in);
- System.out.println("This program reads data for two people and \ncomputes their body mass index(BMI)");
- System.out.print("Input the height of your first person in inches");
- double height1 = pikachu.nextDouble();
- System.out.print("Input the weight of your first person in pounds");
- double weight1 = pikachu.nextDouble();
- System.out.println();
- System.out.print("Input the height of the second person in inches");
- double height2 = pikachu.nextDouble();
- System.out.print("Input the weight of the second person in pounds");
- double weight2 = pikachu.nextDouble();
- double BMI1 = Calculation1(height1, weight1);
- double BMI2 = Calculation2(height2, weight2);
- System.out.println("Person 1 BMI =" + BMI1);
- if(BMI1 >= 30){
- System.out.println("obese");
- } else if(25.0 <= BMI1 && BMI1 <= 29.9)
- {
- System.out.println("overweight");
- } else if(18.5 <= BMI1 && BMI1 <= 24.9){
- System.out.println("normal");
- } else{ // BMI1 < 18.5
- System.out.println("underweight");
- }
- System.out.println("Person 2 BMI =" + BMI2);
- if(BMI2 >= 30){
- System.out.println("obese");
- } else if(25.0 <= BMI2 && BMI2 <= 29.9)
- {
- System.out.println("overweight");
- } else if(18.5 <= BMI2 && BMI2 <= 24.9){
- System.out.println("normal");
- } else{ // BMI2 <18.5
- System.out.println("underweight");
- }
- double Difference = (BMI1-BMI2);
- System.out.println("Difference =" + Difference);
- }
- public static double Calculation1(double height1, double weight1)
- {
- double BMI1 = (weight1/(height1*height1)*703);
- return BMI1;
- }
- public static double Calculation2( double height2, double weight2)
- {
- double BMI2 = (weight2/(height2*height2)*703);
- return BMI2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement