TDEE.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright (c) 2018 Muhammad M. Imtiaz
  2. // This Work is subject to the terms of the Universal Permissive License,
  3. // Version 1.0. If a copy of the licence was not distributed with this Work,
  4. // you can obtain one at <https://oss.oracle.com/licenses/upl/>.
  5. // Muhammad M. Imtiaz
  6. // Computes the TDEE for a person based on data they provide about themselves.
  7. // Friday 19 October 2018
  8. public class TDEE {
  9. public static void main(String[] args) {
  10. String name;
  11. double BMR;
  12. String gender;
  13. double activityLevel = 0;
  14. double TDEE;
  15. java.util.Scanner in = new java.util.Scanner(System.in);
  16. System.out.print("Please enter your name: ");
  17. name = in.nextLine();
  18. System.out.print("Please enter your BMR: ");
  19. BMR = in.nextDouble();
  20. System.out.print("Please enter your gender (M/F): ");
  21. gender = in.next().toUpperCase();
  22. System.out.println();
  23. System.out.println("Select Your Activity Level");
  24. System.out.println("[0] Resting (Sleeping, Reclining)");
  25. System.out.println("[1] Sedentary (Minimal Movement)");
  26. System.out.println("[2] Light (Sitting, Standing)");
  27. System.out.println("[3] Moderate (Light Manual Labour, Dancing, Riding Bike");
  28. System.out.println("[4] Very Active (Team Sports, Hard Manual Labour");
  29. System.out.println("[5] Extremely Active (Full-time Athlete, Heavy Manual Labour)");
  30. System.out.println();
  31. System.out.print("Enter the number corresponding to your activity level: ");
  32. switch(in.nextInt()) {
  33. case 0:
  34. activityLevel = 1;
  35. break;
  36. case 1:
  37. activityLevel = 1.3;
  38. break;
  39. case 2:
  40. if(gender == "M")
  41. activityLevel = 1.6;
  42. else
  43. activityLevel = 1.5;
  44. break;
  45. case 3:
  46. if(gender == "M")
  47. activityLevel = 1.7;
  48. else
  49. activityLevel = 1.6;
  50. break;
  51. case 4:
  52. if(gender == "M")
  53. activityLevel = 2.1;
  54. else
  55. activityLevel = 1.9;
  56. break;
  57. case 5:
  58. if(gender == "M")
  59. activityLevel = 2.4;
  60. else
  61. activityLevel = 2.2;
  62. break;
  63. default:
  64. System.out.println("That is an invalid option.");
  65. }
  66. TDEE = BMR * activityLevel;
  67. System.out.println();
  68. System.out.print("Name: " + name);
  69. System.out.println("\tGender: " + gender);
  70. System.out.print("BMR: " + BMR);
  71. System.out.println("\tActivity Factor: " + activityLevel);
  72. System.out.println("TDEE: " + TDEE);
  73. }
  74. }