Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Labb3Upg1BMI {
- public static void main(String[] args) {
- double BMI;
- int weight;
- double length;
- String sex;
- int age;
- Scanner input = new Scanner(System.in);
- System.out.print("Input weight(KG): ");
- weight = input.nextInt();
- System.out.print("Input length(CM): ");
- length = input.nextDouble();
- System.out.print("Input sex(M/F): ");
- sex = input.nextLine();
- System.out.print("Input age(Yrs): ");
- age = input.nextInt();
- input.close();
- BMI = weight / (length * length);
- double bfm = (1.2 * BMI) + (0.23 * age) - 16.2;
- double bff = (1.2 * BMI) + (0.23 * age) - 5.4;
- if (sex.equals("M")){
- System.out.println("Your body fat % is: " + bfm + "%.");
- }
- else if (sex.equals("F")){
- System.out.println("Your body fat % is: " + bff +"%. ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement