Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class CandyCalculatorGender
  4. {
  5. public static void main(String[] args)
  6. {
  7.  
  8. Scanner keyboard = new Scanner (System.in);
  9. int age;
  10. int weight;
  11. int height;
  12. int gender;
  13.  
  14. System.out.println("This program calculates the number of 230 calorie candy bars to maintain your weight.");
  15. System.out.println("What is your age in years?");
  16. age = keyboard.nextInt();
  17. System.out.println("What is your weight in pounds?");
  18. weight = keyboard.nextInt();
  19. System.out.println("What is your total height in inches?");
  20. height = keyboard.nextInt();
  21. System.out.println("What is your gender? male/female?");
  22. gender = keyboard.nextInt();
  23.  
  24. double caloriesMale, caloriesFemale;
  25.  
  26. caloriesMale = 655 + (4.3*weight) + (4.7*height) - (4.7*age);
  27. caloriesFemale = 66 + (6.3*weight) + (12.9*height) - (6.8*age);
  28.  
  29. if ("male".equals(gender)){
  30. System.out.println("A male with those measurements should " +
  31. (caloriesMale / 230) +
  32. " candy bars per day to maintain his weight.");
  33. }
  34. else if ("female".equals(gender)){
  35. System.out.println("A female with those measurements should " +
  36. (caloriesFemale / 230) +
  37. " candy bars per day to maintain her weight.");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement