BMR.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. public class BMR {
  6. public static void main(String[] args) {
  7. java.util.Scanner input = new java.util.Scanner(System.in);
  8. String name;
  9. String gender;
  10. int age;
  11. int heightInches;
  12. int weightPounds;
  13. double heightCm;
  14. double weightKg;
  15. double BMR;
  16. System.out.print("Enter your name: ");
  17. name = input.nextLine();
  18. System.out.print("Gender (M or F): ");
  19. gender = input.next();
  20. System.out.print("Enter your age: ");
  21. age = input.nextInt();
  22. System.out.print("Height in inches: ");
  23. heightInches = input.nextInt();
  24. System.out.print("Weight in pounds: ");
  25. weightPounds = input.nextInt();
  26. heightCm = heightInches * 2.54;
  27. weightKg = weightPounds * 0.45359237;
  28. BMR = 10 * weightKg + 6.25 * heightCm;
  29. if(gender.toUpperCase() == "M")
  30. BMR += 5;
  31. else
  32. BMR -= 161;
  33. System.out.println("Name: " + name);
  34. System.out.println("Gender:" + gender);
  35. System.out.println("Age: " + age);
  36. System.out.println("Weight (kg): " + weightKg);
  37. System.out.println("Height (cm): " + heightCm);
  38. System.out.println("Basal Metabolic Rate: " + BMR + " calories per day");
  39. }
  40. }