Question: IN JAVA PLEASE, THANKS! Write a program that allows the user to perform 3 health checks: body mass index (BMI), cholesterol, and blood pressure. The

IN JAVA PLEASE, THANKS!

Write a program that allows the user to perform 3 health checks: body mass index (BMI), cholesterol, and blood pressure. The ranges and the results are presented in table for each health check. This range information is presented to the user based on the selected health check. Health Check Range Result BMI Less than 18.5 Between 18.5 and 25 Greater than 25 Underweight Normal Overweight Cholesterol Less than 200 Between 200 and 239 Greater than 239 Good Borderline High Blood Pressure Top number is less than or equal to 120 and Bottom number is less than or equal to 80 Top number is between 121 and 129 and Bottom number is less than or equal to 80 Top number is between 130 and 139 and Bottom number is between 80 and 89 Anything else Normal Elevated Stage 1 high blood pressure Stage 2 high blood pressure The formula for calculating BMI is: BMI = 703 X () () () Specifications Write code that: Allows the user to repeatedly perform one of the health checks Gracefully handles invalid menu selection see output example #3 below. Step 1: Call getHealthCheck method to obtain which health check user wants to perform o This method displays the health check menu and prompts user to select an option

Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit Which health check? Select option 1, 2, 3, or 4: o The method reads health check option and ensures user entry is a valid option (a number between 1 & 4) o Allows user to reenter health check option if their entry is invalid until it is valid. o Method returns a valid health check option - a number between 1 and 4. Step 2: in main, create a while loop to perform health checks as many times as user desires. o The loop in main could look something like the code shown below: o Note, the code must allow the user to quit the program before any health checks are performed, that is, if the user enters 4 on the first menu. The getHealthCheck method must be called before the while loop in main to allow user to quit before any health checks see example output #2 below. Scanner userInput = new Scanner(System.in); // Prompt user for which health check to perform int healthCheck = getHealthCheck(userInput); while (healthCheck != EXIT) { // Based on selected option, perform health check by calling // correct method and display results // Prompt user to see if they want to perform another health check healthCheck = getHealthCheck(userInput); } o Step 2a: Call correct health method based on value returned by getHealthCheck o Step 2b: Display results for the selected health check by calling the method displayResults inside the main while loop. o Step 2c: Call getHealthCheck method to determine if user wants to do it again 5. Design your program to use the following methods: // Prompt user for which health check to perform and validates user input. // Returns a valid menu option.

public static int getHealthCheck (Scanner userInput) // Prompt user for values needed to compute body mass index (BMI) & computes BMI. // Returns the computed BMI value. public static double computeBMI(Scanner userInput) // Checks the range for the body mass index and returns the result as a string: // underweight, normal, or overweight. public static String checkBMI(double bodyMassIndex) // Checks the range for the cholesterol and returns the result as a string: // good, borderline, high public static String checkCholesterol(int cholesterol ) // Checks the range for the blood pressure and returns the result as a string: // normal blood pressure, elevated blood pressure, stage 1 high blood pressure, // stage 2 high blood pressure public static String checkBloodPressure(int topNumber, int bottomNumber ) // Displays the results for a specific health check. // Requires using a switch statement. public static void displayResults(int healthCheck, String healthCheckResult ) Must Do and Tips Must Do: In your design notebook, include pseudocode for these 2 methods: main checkBloodPressure Must Do: Create each method in step 5 as defined in assignment sheet Create the methods as defined in step 5 with the given return type and parameters You can add more methods, but you must write all the methods in step 5 as shown Do not change the return types or parameters of these methods. Must Do: The value returned by a method must be stored in a variable To help develop a strong understanding of methods, you must store the value returned by any value-returning method in a variable. This means you are not allowed to use a method call as an argument of another method call. For example, you cannot use the checkBMI method call as an argument of the displayResults call o displayResults(BMI, checkBMI(bmi)); Instead, you must store the value returned from a method in a variable.

o String bmiResult = checkBMI(bmi); o displayResults(BMI, bmiResult); Must Do: When computing BMI enter users height in feet and inches Allow user to enter height in feet and inches for BMI and perform conversion to inches inside the computeBMI method. See the first example output below. Must Do: Call displayResults in main The health check methods should perform only 1 task, that is, a specific health check and return a String. The displayResults method is the only method where results will be displayed. Must Do: Use a switch statement A switch statement must be used in the method displayResults Must Do: Handle invalid user input The code must handle user input validation for the entered health check. o When an invalid health check option is entered, repeat the select health check to perform prompt until a valid option is entered. Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit Which health check? Select option 1, 2, 3, or 4: 0 0 is not a valid entry - try again Which health check? Select option 1, 2, 3, or 4: 5 5 is not a valid entry - try again Which health check? Select option 1, 2, 3, or 4: 3 Enter cholesterol: 230 *************************************** Cholesterol Result = Borderline *************************************** Tip: Be sure to properly layout your code when including methods

public class ProperCodeLayoutWithMethods { public static void main(String[] args) { // Code inside main to prompt user for which health check int healthCheck = getHealthCheck(userInput); } // main // Methods go after the closing curly brace for main public static int getHealthCheck (Scanner userInput) { // Code to ask user which health check to perform } // getHealthCheck } // ProperCodeLayoutWithMethods End of main class is after all methods Tip: New grading section for methods on grader sheet On the grader sheet, under quality, the section regarding methods now applies. Commenting of methods o `Each method must have a comment above the method explaining its purpose. o Longer methods should have comments within the method as well. // Prompt user for health check to perform and validates user input public static int getHealthCheck (Scanner userInput) Tip: Write code incrementally Write code incrementally, for example: o Step 1: write code for each method o Step 2: test each method to make sure the method produces correct results o Step 3: build code in main around the methods Output Your output may look similar to the following: Example #1 Valid Input

****************************** Welcome to the Health Checker ****************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit The bolded values are the Which health check? Select option 1, 2, 3, or 4: 1 values entered during run Enter weight in pounds: 160 Enter height in feet: 5 Enter height in inches: 10 *************************************** BMI Result = Normal *************************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit Running program again for a different health check Which health check? Select option 1, 2, 3, or 4: 3 Enter cholesterol: 230 *************************************** Cholesterol Result = Borderline *************************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit User ending the program

Which health check? Select option 1, 2, 3, or 4: 4 Have a healthy day! Goodbye Example #2 User performs no health checks Your code must allow the user to quit without performing any health checks. ****************************** Welcome to the Health Checker ****************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit Which health check? Select option 1, 2, 3, or 4: 4 Have a heathy day! Goodbye Example #3 Handle invalid input Your code must check for valid input when prompting user for which health check. When input is invalid, keep prompting until a valid shape is entered. ****************************** Welcome to the Health Checker ****************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit When invalid menu option, tell user to reenter until valid option entered Which health check? Select option 1, 2, 3, or 4: 0 0 is not a valid entry - try again Which health check? Select option 1, 2, 3, or 4: 5

5 is not a valid entry - try again Which health check? Select option 1, 2, 3, or 4: 2 Enter top blood pressure number (systolic): 120 Enter bottom blood pressure number (diastolic): 90 *************************************** Blood Pressure Result = Stage 2 high blood pressure (hypertension) *************************************** Option Health Check ------------------------ 1 BMI 2 Blood Pressure 3 Cholesterol 4 Exit Which health check? Select option 1, 2, 3, or 4: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!