CoineTre

PreExam11/20_02Calories Calculator

Nov 17th, 2020 (edited)
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CalorieCalculator {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner (System.in);
  6.         String sex = scanner.nextLine();
  7.         double kg = Double.parseDouble(scanner.nextLine());
  8.         double m = Double.parseDouble(scanner.nextLine()) *100;
  9.         int age = Integer.parseInt(scanner.nextLine());
  10.         String activity  = scanner.nextLine();
  11.         double bnm;
  12.         if(sex.equals("m")) {
  13.             bnm = 66+ (13.7 * kg)+(5*m)-(6.8*age);
  14.         }else{
  15.             bnm = 655 + (9.6 * kg)+(1.8*m)-(4.7*age);
  16.         }
  17.         switch (activity){
  18.             case("sedentary"):
  19.                 bnm = bnm * 1.2;
  20.                 break;
  21.             case("lightly active"):
  22.                 bnm = bnm * 1.375;
  23.                 break;
  24.             case("moderately active"):
  25.                 bnm = bnm * 1.55;
  26.                 break;
  27.             case("very active"):
  28.                 bnm = bnm * 1.725;
  29.                 break;
  30.         }
  31.         System.out.printf("To maintain your current weight you will need %.0f calories per day.",Math.ceil(bnm));
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment