Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

you are to write a java program that records the health profile. you will design

ID: 3810860 • Letter: Y

Question

you are to write a java program that records the health profile. you will design a “starter” HealthProfile program for a person. The program should include the person’s age, height (in inches), and weight (in pounds). The program also should include functions that calculate maximum heart rate and target heart rate, and body mass index (BMI). The program should prompt for the person’s information from that variable – including age, height and weight – then it should calculate and display the BMI, maximum heart rate and target heart rate range. Use the following formula to calculate BMI, maximum heart rate and target heart rate range. formular Maximum Heart Rate = 220 – age Target Heart Rate Range = 50 – 80 % of Maximum Heart Rate.

The program should notify to the user what the BMI value means. BMI values will be determined as follows: If BMI value is in 19 to 24, he/she is "Normal". If BMI value is in 25 to 29, he/she is "Overweight". If BMI value is in 30 to 39, he/she is "Obese". If BMI value is bigger than 40, he/she is "Extreme Obesity". The program should keep asking the user to input data if he/she has more to calculate. The program allows decimal places. Therefore, variables used in this program should have the proper data type. Output of the program should be well formatted, readable, and professional. 1. Declare variable names and proper data type of each variable. 2. Import scanner class for user input. 3. Add data entered by a user using do/while loop. 4. Calculate and decide BMI value. 5. Calculate Maximum heart rate and target heart rate. 6. All output values must have two decimal places. 7. Well-formatted, readable, and professional output. 8. Ask a user input more data after each calculation. If no more data to input, program stops. 9. Your output should look like following:


   Enter height in inches: 68.5
Enter weight in pounds: 220  
Enter your age: 20
   Your BMI value is 32.96 You are obese
   Maximum Heart Rate: 200.00   Target Heart Rate 50 to 80 percentage --> 100.00~160.00
   Do you have more data to calculate?   <0 to continue or 1 for stop> -->0      Enter height in inches: 70.7   Enter weight in pounds: 185.8   Enter your age: 35
   Your BMI value is 26.13 You are overweight
   Maximum Heart Rate: 185.00   Target Heart Rate 50 to 80 percentage --> 92.50~148.00
   Do you have more data to calculate?   <0 to continue or 1 for stop> -->0
   Enter height in inches: 72   Enter weight in pounds: 173   Enter your age: 42
   Your BMI value is 23.46 You are normal
   Maximum Heart Rate: 178.00   Target Heart Rate 50 to 80 percentage --> 89.00~142.40     

Do you have more data to calculate?   <0 to continue or 1 for stop> -->1 ****************************************************************   Thank you for using Health Profiler

Explanation / Answer

Program:-

import java.io.*;
import java.util.Scanner;
import java.text.DecimalFormat;
public class HealthProfile
{
    public static void main(String[] args)
    {
        int age,ch;
        double height,weight,bmi,max_heart_rate,max,min;
        Scanner scan=new Scanner(System.in);
        DecimalFormat df2 = new DecimalFormat("##.##");     //for setting decimal point to two places
        do
        {
            System.out.print(" Enter height in inches:");
            height=scan.nextFloat();        //read height
            System.out.print(" Enter weight in pounds:");
            weight=scan.nextFloat();        //read weight
            System.out.print(" Enter Your Age :");
            age=scan.nextInt();             //read age
          
            height=height*0.025;    //convert height to meters
            weight=weight*0.45;     //convert weight to kilograms
            bmi=weight/(height*height); //calculate bmi= wight/height^2
          
            bmi=Double.valueOf(df2.format(bmi));    //convert to two decimal points
            System.out.print("Your BMI value is "+bmi);
          
            if(bmi<25)
                System.out.print(" You are Normal");
            else if(bmi>=25&&bmi<30)
                System.out.print(" You are OverWeight");
            else if(bmi>=30&&bmi<40)
                System.out.print(" You are Obese");
            else
                System.out.print(" You are Extreme Obesity");
          
            max_heart_rate=220-age;
            System.out.print(" Maximum Heart rate is :"+max_heart_rate);
          
            min=max_heart_rate*(50.0/100.0);    //calculate maximum heart rate range
            max=max_heart_rate*(80.0/100.0);
            System.out.println(" Target Heart Rate 50 to 80 percentage -->"+min+"~"+max);
          
            System.out.print("Do you have more data to calculate?   <0 to continue or 1 for stop> -->");
            ch=scan.nextInt();
        }while(ch==0); //checking for continue
        System.out.println("****************************************************************");
        System.out.println("Thank you for using Health Profiler");
    }
}


Output:-
run:

Enter height in inches:68.5

Enter weight in pounds:220

Enter Your Age :20
Your BMI value is 33.76 You are Obese
Maximum Heart rate is :200.0 Target Heart Rate 50 to 80 percentage -->100.0~160.0
Do you have more data to calculate?   <0 to continue or 1 for stop> -->0

Enter height in inches:70.7

Enter weight in pounds:185.8

Enter Your Age :35
Your BMI value is 26.76 You are OverWeight
Maximum Heart rate is :185.0 Target Heart Rate 50 to 80 percentage -->92.5~148.0
Do you have more data to calculate?   <0 to continue or 1 for stop> -->0

Enter height in inches:72

Enter weight in pounds:173

Enter Your Age :42
Your BMI value is 24.03 You are Normal
Maximum Heart rate is :178.0 Target Heart Rate 50 to 80 percentage -->89.0~142.4
Do you have more data to calculate?   <0 to continue or 1 for stop> -->0

Enter height in inches:60

Enter weight in pounds:220

Enter Your Age :25
Your BMI value is 44.0 You are Extreme Obesity
Maximum Heart rate is :195.0 Target Heart Rate 50 to 80 percentage -->97.5~156.0
Do you have more data to calculate?   <0 to continue or 1 for stop> -->0

Enter height in inches:64.8

Enter weight in pounds:132.277

Enter Your Age :25
Your BMI value is 22.68 You are Normal
Maximum Heart rate is :195.0 Target Heart Rate 50 to 80 percentage -->97.5~156.0
Do you have more data to calculate?   <0 to continue or 1 for stop> -->1
****************************************************************
Thank you for using Health Profiler
BUILD SUCCESSFUL (total time: 6 minutes 32 seconds)