Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String gender = scanner.nextLine();
- double weight = Double.parseDouble(scanner.nextLine()),
- height = Double.parseDouble(scanner.nextLine()),
- basalMetabolicRate, coefficientActivity;
- int age = Integer.parseInt(scanner.nextLine());
- String physicalActivity = scanner.nextLine();
- if (gender.equals("m")) {
- basalMetabolicRate = 66 + weight * 13.7 + height * 500 - 6.8 * age;
- } else {
- basalMetabolicRate = 655 + weight * 9.6 + height * 180 - 4.7 * age;
- }
- coefficientActivity = switch (physicalActivity) {
- case "sedentary" -> 1.2;
- case "lightly active" -> 1.375;
- case "moderately active" -> 1.55;
- default -> 1.725;
- };
- int calories = (int) Math.ceil(basalMetabolicRate * coefficientActivity);
- System.out.printf("To maintain your current weight you will need %d calories per day.\n", calories);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement