Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class HowHealthy
- {
- public static void main(String[] args)
- {
- String printGender;
- //creates new scanner class
- Scanner scan = new Scanner(System.in);
- //takes in String name
- System.out.print("\nPerson's name: ");
- String name = scan.nextLine();
- if (name.length() == 0)
- {
- System.out.println("Invalid Name - must have at least one character");
- System.exit(1);
- }
- //takes in gender
- System.out.print(name + ", are you male or female (M/F)? ");
- String gender = scan.nextLine();
- //takes in weight
- System.out.print(name + "'s weight (pounds): ");
- double pounds = scan.nextDouble();
- //takes in height
- System.out.print(name + "'s height (inches): ");
- double inches = scan.nextDouble();
- //takes in age
- System.out.print(name + "'s age (years): ");
- int age = scan.nextInt();
- //prints all activity levels
- System.out.println("Activity Level: Use these categories:");
- System.out.println("\t1 - Sedentary (little or no exercise, desk job)");
- System.out.println("\t2 - Lightly active (light exercise/sports 1-3 days/wk)");
- System.out.println("\t3 - Moderately active (moderate exercise/sports 3-5 days/wk)");
- System.out.println("\t4 - Very active (hard exercise/sports 6-7 days/wk)");
- System.out.println("\t5 - Extra active (hard daily exercise/sports & physical job or\n\t\t 2X day training i.e marathon, contest etc.)");
- //takes in activity level
- System.out.print("How active are you? ");
- int actlevel = scan.nextInt();
- //creates new Healthy object named david
- Healthy david = new Healthy(name, gender, pounds, inches, age, actlevel);
- //prints all inputed information
- System.out.println(david.getName() + "'s information");
- System.out.println("Weight: " + david.getWeight() + " pounds");
- System.out.println("Height: " + david.getHeight() + " inches");
- System.out.println("Age: " + david.getAge() + " years");
- //determines if input is for a male or female
- if (gender.equalsIgnoreCase("M"))
- printGender = "Male";
- else
- printGender = "Female";
- //prints gender, bmr, bmi, and tdee
- System.out.println("These are for a " + printGender + ".");
- System.out.println("");
- System.out.printf("BMR is %.2f\n", david.calcBmr());
- System.out.printf("BMI is %.2f\n", david.calcBmi());
- System.out.printf("TDEE is %.2f\n\n", david.calcTdee());
- System.out.println(david.calcStatus());
- }//main
- }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement