Spring 2004 CS0007: Introduction to Computer Programming Assignment 2: Training Heart Rate |
||||||
Have your old handouts ready as a reference and assignment 1. |
||||||
|
||||||
This assignment is similar in nature to several of the examples we did in class. You will be following the "calculator" style of program that goes: (1) get input, (2) calculate answer, (3) print results. You will be declaring a few variables and using some built-in methods. |
||||||
What
to do |
||||||
You will write a small program to calculate the user's training heart rate (THR). That's how fast your heart should be beating to get the most out of every workout. Your program will specifically be calculating the aerobic zone (there are several different zones - see below for a link to more information). To calculate someone's aerobic THR, you need to use the following formula: THR = ((MaxHeartRate - RestingHeartRate) X
.75) + RestingHeartRate
To find someones
Maximum Heart Rate, just subtract their age from 214. Resting
Heart Rate varies from person to person, but is generally between 60
and 80.
Your program will therefore need to ask the user for his/her age and resting heart rate. Both of these variables should be of type int. You will also need a variable to hold the result, which should be of type double. |
||||||
Sample
output |
||||||
Here is a sample of how your program might look when executed. You don't have to do exactly this, but it should be similar.
Don't worry if your output turns out kind of ugly - formatting doubles when they are printed is a bit hairy, so we'll learn that later. |
||||||
Requirements
& Handing
your work in |
||||||
Before you hand your program in, make sure you meet these requirements:
|
||||||
Suggestions/Hints |
||||||
This is fairly similar to the programs we wrote together in class. My advice is to model your program after them. Note: Do exactly what is asked, please don't make your program do more or less than this. This complicates the grading process which is difficult as it is. If you would like to go above and beyond, that is fine, just don't turn it in. You are always welcomed to visit us during office hours to talk about advanced topics. The THR formula shown here is simplified. If you want to see a full version of THR, have a look at this site. |
||||||
|