Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Daniel on 4/18/2016.
- */
- import java.util.*;
- public class bmiCalculator {
- public static void main(String[] args){
- Scanner c = new Scanner(System.in);
- System.out.println("This program reads data for two people and");
- System.out.println("computes their body mass index (BMI).\n");
- double person1 = bmi(c);
- double person2 = bmi(c);
- health(person1,1);
- health(person2,2);
- System.out.println("Difference = " + Math.abs(person1 - person2));
- }
- public static double bmi(Scanner c){
- System.out.println("Enter next person's information:");
- System.out.print("height (in inches)?");
- double height = c.nextDouble();
- System.out.print("weight (in pounds)");
- double weight = c.nextDouble();
- System.out.println();
- double BMI = (weight/(height*height)) *703;
- return BMI;
- }
- public static void health(double p,int pn){
- System.out.println("Person" + pn + " BMI = "+p + pn);
- if (p >= 30.0){
- System.out.println("Obese");
- }
- if (p >= 25.0 && p <=29.9){
- System.out.println("Overweight");
- }
- if(p >= 18.5 && p <=24.9){
- System.out.println("Normal");
- }
- if(p < 18.5){
- System.out.println("Underweight");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment