1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // Copyright (c) 2018 Muhammad M. Imtiaz
- // This Work is subject to the terms of the Universal Permissive License,
- // Version 1.0. If a copy of the licence was not distributed with this Work,
- // you can obtain one at <https://oss.oracle.com/licenses/upl/>.
- // Muhammad M. Imtiaz
- // Computes the TDEE for a person based on data they provide about themselves.
- // Friday 19 October 2018
- public class TDEE {
- public static void main(String[] args) {
- String name;
- double BMR;
- String gender;
- double activityLevel = 0;
- double TDEE;
- java.util.Scanner in = new java.util.Scanner(System.in);
- System.out.print("Please enter your name: ");
- name = in.nextLine();
- System.out.print("Please enter your BMR: ");
- BMR = in.nextDouble();
- System.out.print("Please enter your gender (M/F): ");
- gender = in.next().toUpperCase();
- System.out.println();
- System.out.println("Select Your Activity Level");
- System.out.println("[0] Resting (Sleeping, Reclining)");
- System.out.println("[1] Sedentary (Minimal Movement)");
- System.out.println("[2] Light (Sitting, Standing)");
- System.out.println("[3] Moderate (Light Manual Labour, Dancing, Riding Bike");
- System.out.println("[4] Very Active (Team Sports, Hard Manual Labour");
- System.out.println("[5] Extremely Active (Full-time Athlete, Heavy Manual Labour)");
- System.out.println();
- System.out.print("Enter the number corresponding to your activity level: ");
- switch(in.nextInt()) {
- case 0:
- activityLevel = 1;
- break;
- case 1:
- activityLevel = 1.3;
- break;
- case 2:
- if(gender == "M")
- activityLevel = 1.6;
- else
- activityLevel = 1.5;
- break;
- case 3:
- if(gender == "M")
- activityLevel = 1.7;
- else
- activityLevel = 1.6;
- break;
- case 4:
- if(gender == "M")
- activityLevel = 2.1;
- else
- activityLevel = 1.9;
- break;
- case 5:
- if(gender == "M")
- activityLevel = 2.4;
- else
- activityLevel = 2.2;
- break;
- default:
- System.out.println("That is an invalid option.");
- }
- TDEE = BMR * activityLevel;
- System.out.println();
- System.out.print("Name: " + name);
- System.out.println("\tGender: " + gender);
- System.out.print("BMR: " + BMR);
- System.out.println("\tActivity Factor: " + activityLevel);
- System.out.println("TDEE: " + TDEE);
- }
- }
|