yovkovbpfps

EXAM Calorie Calculator

May 3rd, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. // write your code here
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. char sex = scanner.nextLine().charAt(0);
  10. double weight = Double.parseDouble(scanner.nextLine());
  11. double height = Double.parseDouble(scanner.nextLine());
  12. int age = Integer.parseInt(scanner.nextLine());
  13. String activity = scanner.nextLine();
  14. height = height * 100;
  15. double bnm = 0;
  16. if (sex == 'm') {
  17.  
  18. bnm = 66 + (13.7 * weight) + (5 * height) - (6.8 * age);
  19. } else if (sex == 'f')
  20. {
  21. bnm = 655 + (9.6 * weight) + (1.8 * height) - (4.7 * age);
  22.  
  23. }
  24. double calories = 0;
  25. if (activity.equals("sedentary")) {
  26. calories = bnm * 1.2;
  27. } else if (activity.equals("lightly active")) {
  28. calories = bnm * 1.375;
  29. } else if (activity.equals("moderately active")) {
  30. calories = bnm * 1.55;
  31.  
  32. } else if (activity.equals("very active")) {
  33. calories = bnm * 1.725;
  34.  
  35. }
  36. calories = Math.ceil(calories);
  37. System.out.printf("To maintain your current weight you will need %.0f calories per day.", calories);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment