Question

In: Computer Science

12.9 (Target-Heart-Rate Calculator App) While exercising, you can use a heart-rate monitor to see that your...

12.9 (Target-Heart-Rate Calculator App) While exercising, you can use a heart-rate monitor to see that your heart rate stays within a safe range suggested by your trainers and doctors. According to the American Heart Association (AHA), the formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years (http://bit.ly/AHATargetHeartRates). Your target heart rate is a range that is 50–85% of your maximum heart rate. [Note: These formulas are estimates provided by the AHA. Maximum and target heart rates may vary based on the health, fitness and gender of the individual. Always consult a physician or qualified health care professional before beginning or modifying an exercise program.] Write an app that inputs the person’s age, then calculates and displays the person’s maximum heart rate and target-heart-rate range.

(code in java please)

Solutions

Expert Solution

You are making an app so it should be assumed that you will be working with GUI programming.
so first we need to enter user's basic details like name, age, gender etc.

for taking input make respective variables like String Name, Char gender, int age;
and declare any other variables which you like.

after that you just take input from user from a textbox/textfield.
like assign and id or variable name to the textbox/textfield.
ex: nameTF you can give name to the text field in which you will input user's name.

EditText name = (EditText) findViewById(R.id.EnterText);
Button B1 = (Button) findViewById(R.id.nameTF);
String str = text.getText().toString();

This code can be done in android studio for making android apps.
after that respective codes have been written we can make the formula for calculating heart rate.

As its said above that the target heart rate is calculated as 220-age(in years)

so create a variable as
int targetHR = 220 - age;
Or whatever is the formula, just make a variable and apply operations on it. You can make that variable in float also. That will be good option.

After that you just need to output that variable on some label or text view.
Use the setText method as

//write this in xml file
<TextView
    android:id="@+id/heartRateTV"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

//and write this in the java file
TextView hr = (TextView)findViewById(R.id.heartRateTV);
hr.setText(""+targetHR);

This will display the output the values of the target heart rate that you want to show to the user.


Related Solutions

what observation you can get when you measure heart rate using telemetry? (Polar Heart Rate Monitor)
what observation you can get when you measure heart rate using telemetry? (Polar Heart Rate Monitor)
Instructions: In this assignment, you use linear regression to calculate the expected after exercising heart rate....
Instructions: In this assignment, you use linear regression to calculate the expected after exercising heart rate. Steps: 1. Open the Heart Rate database and identify the X-variable (resting) and the Y-variable (after exercise). 2. Use the Scatter Plot function in the Insert Charts section of Excel to create a scatter plot of the X and Y variables 3. Add a trendline to the scatter plot (Find and View a YouTube video on how to do this if you need help)...
What is your maximum heart rate? What is your target heart training zone?
What is your maximum heart rate? What is your target heart training zone?
What are two strategies you can use to monitor your own work to ensure the required...
What are two strategies you can use to monitor your own work to ensure the required standard of support is maintained?
Scenario: Your supervisor understands that a hacker can use a sniffer to monitor and analyze the...
Scenario: Your supervisor understands that a hacker can use a sniffer to monitor and analyze the organization's network traffic and recommends that you use the media access control (MAC) flooding as a countermeasure. However, you disagree. Why? What countermeasure, in your opinion, can be employed to defeat the hacker's sniffing attacks? When responding to classmates, discuss whether you agree with their choices of countermeasures and explain your reasoning.
Choose an app or product that you like and use a lot, describe how you can...
Choose an app or product that you like and use a lot, describe how you can redesign it and why. Make a concept paper about the product proposal comprising the following information: Introduction about your Product Product Development Product Design Product Application
In this assignment, you will be required to use the Heart Rate Dataset to complete the...
In this assignment, you will be required to use the Heart Rate Dataset to complete the following: Identify the types of data represented by variables The range or types of values for each variable Give a brief written description of the variables, and how they are used in the data set. Steps Open the Heart Rate Dataset in Excel Identify each of the variables contained in the dataset by type Identify the type of data each variable represents (e.g., qualitative...
This is for C++ You must use either a FOR, WHILE, or DO-WHILE loop in your...
This is for C++ You must use either a FOR, WHILE, or DO-WHILE loop in your solution for this problem. Write a quick main console program to output the following checker pattern to the console: #_#_#_#_# _#_#_#_#_ #_#_#_#_# _#_#_#_#_ #_#_#_#_#
Use financial calculator to answer the question a. You are saving for your retirement. You have...
Use financial calculator to answer the question a. You are saving for your retirement. You have decided that one year from today you will deposit 4 percent of your annual salary in an account which will earn 8 percent per year. Your salary currently (today) is $70,000, and it will increase at 2 percent per year throughout your career. How much money will you have for your retirement, which will begin in 35 years? Assume your first payment into the...
For this part you will need to use your calculator. What is the Monthly Mortgage Payment...
For this part you will need to use your calculator. What is the Monthly Mortgage Payment on a $125,000 Home with an 80% LTV with a 5% Interest Rate, 30-Year Fixed Rate Mortgage (Constant Payment Mortgage)? $536.82 What is the Monthly Mortgage Payment on a $125,000 Home with an 80% LTV with a 6% Interest Rate, 30-Year Fixed Rate Mortgage (Constant Payment Mortgage)? $599.55 How much more with the person with the mortgage in question #8 pay over the person...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT