Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Labb3Upg1BMI {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         double BMI;
  8.         int weight;
  9.         double length;
  10.         String sex;
  11.         int age;
  12.        
  13.         Scanner input = new Scanner(System.in);
  14.         System.out.print("Input weight(KG): ");
  15.         weight = input.nextInt();
  16.         System.out.print("Input length(CM): ");
  17.         length = input.nextDouble();
  18.         System.out.print("Input sex(M/F): ");
  19.         sex = input.nextLine();
  20.         System.out.print("Input age(Yrs): ");
  21.         age = input.nextInt();
  22.        
  23.         input.close();
  24.         BMI = weight / (length * length);
  25.  
  26. double bfm = (1.2 * BMI) + (0.23 * age) - 16.2;
  27. double bff = (1.2 * BMI) + (0.23 * age) - 5.4;
  28.  
  29.         if (sex.equals("M")){
  30.     System.out.println("Your body fat % is: " + bfm + "%.");
  31.         }
  32.     else if (sex.equals("F")){
  33.     System.out.println("Your body fat % is: " + bff +"%. ");
  34.        
  35.     }
  36.     }
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement