Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class CandyCalculatorGender
- {
- public static void main(String[] args)
- {
- Scanner keyboard = new Scanner (System.in);
- int age;
- int weight;
- int height;
- int gender;
- System.out.println("This program calculates the number of 230 calorie candy bars to maintain your weight.");
- System.out.println("What is your age in years?");
- age = keyboard.nextInt();
- System.out.println("What is your weight in pounds?");
- weight = keyboard.nextInt();
- System.out.println("What is your total height in inches?");
- height = keyboard.nextInt();
- System.out.println("What is your gender? male/female?");
- gender = keyboard.nextInt();
- double caloriesMale, caloriesFemale;
- caloriesMale = 655 + (4.3*weight) + (4.7*height) - (4.7*age);
- caloriesFemale = 66 + (6.3*weight) + (12.9*height) - (6.8*age);
- if ("male".equals(gender)){
- System.out.println("A male with those measurements should " +
- (caloriesMale / 230) +
- " candy bars per day to maintain his weight.");
- }
- else if ("female".equals(gender)){
- System.out.println("A female with those measurements should " +
- (caloriesFemale / 230) +
- " candy bars per day to maintain her weight.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement