Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. /**
  2. * @Sean Wilson
  3. * @version 11/15/10
  4. */
  5. import java.util.Scanner;
  6. public class calculator
  7. {
  8. public static void main(String[] args)
  9. {
  10. double activityFactor = 0;
  11.  
  12. Scanner intInput = new Scanner(System.in);
  13. Scanner stringInput = new Scanner(System.in);
  14. System.out.print("Please enter your name: ");
  15. String name = stringInput.nextLine();
  16. System.out.print("Please enter your BMR: ");
  17. int BMR = intInput.nextInt();
  18. System.out.print("Please enter your Gender (M/F): ");
  19. String genderTemp1 = stringInput.nextLine();
  20. char genderTemp2 = genderTemp1.charAt(0);
  21. char gender = Character.toUpperCase(genderTemp2);
  22.  
  23. if (gender != 'M' || gender != 'F')
  24. System.out.println("Wrong Input");
  25. else
  26. {
  27.  
  28. System.out.println("");
  29. System.out.println("Select Your Activity Level");
  30. System.out.println("[A] Resting (Sleeping, Reclining)");
  31. System.out.println("[B] Sedentary (Minimal Movement)");
  32. System.out.println("[C] Light (Sitting, Standing)");
  33. System.out.println("[D] Moderate (Light Manual Labor, Dancing, Riding Bike)");
  34. System.out.println("[E] Very Active (Team Sports, Hard Manual Labor)");
  35. System.out.println("[F] Extremely Active (Full-Time Athelete, Heavy Manual Labor)" + "\n");
  36. System.out.print("Enter the letter corresponding to your activity level: ");
  37. String menuChoice = stringInput.nextLine();
  38. System.out.println("");
  39.  
  40. if (gender == 'M')
  41. {
  42.  
  43. if(menuChoice.equalsIgnoreCase("A"))
  44. {
  45. activityFactor = 1.0;
  46. }
  47.  
  48. else if(menuChoice.equalsIgnoreCase("B"))
  49. {
  50. activityFactor = 1.3;
  51. }
  52.  
  53. else if(menuChoice.equalsIgnoreCase("C"))
  54. {
  55. activityFactor = 1.6;
  56. }
  57.  
  58. else if(menuChoice.equalsIgnoreCase("D"))
  59. {
  60. activityFactor = 1.7;
  61. }
  62.  
  63. else if(menuChoice.equalsIgnoreCase("E"))
  64. {
  65. activityFactor = 2.1;
  66. }
  67.  
  68. else if(menuChoice.equalsIgnoreCase("F"))
  69. {
  70. activityFactor = 2.4;
  71. }
  72.  
  73. else
  74. {
  75. activityFactor = 0;
  76. System.out.print("Invalid Menu Selection");
  77. }
  78. }
  79. else if (gender == 'F')
  80. {
  81. if(menuChoice.equalsIgnoreCase("A"))
  82. {
  83. activityFactor = 1.0;
  84. }
  85.  
  86. else if(menuChoice.equalsIgnoreCase("B"))
  87. {
  88. activityFactor = 1.3;
  89. }
  90.  
  91. else if(menuChoice.equalsIgnoreCase("C"))
  92. {
  93. activityFactor = 1.5;
  94. }
  95.  
  96. else if(menuChoice.equalsIgnoreCase("D"))
  97. {
  98. activityFactor = 1.6;
  99. }
  100.  
  101. else if(menuChoice.equalsIgnoreCase("E"))
  102. {
  103. activityFactor = 1.9;
  104. }
  105.  
  106. else if(menuChoice.equalsIgnoreCase("F"))
  107. {
  108. activityFactor = 2.2;
  109. }
  110.  
  111. }
  112. double TDEE = BMR * activityFactor;
  113.  
  114. System.out.print("Name: " + name + "\t\t\tGender: " + gender + "\n");
  115. System.out.print("BMR: " + BMR + " calories\t\tActivity Factor: " + activityFactor + "\n");
  116. System.out.print("TDEE: " + TDEE + " calories");
  117. }
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement