Error in Code, unsure how to correct

I am getting an error in my code, and I do not know how to fix it. Write a program to calculate target heart rate during fitness training. This program has two functions: main and heartRateCalculator. Please do the following:
(a) In the main function, ask the user to enter age and resting heart rate.
(b) In the main function, invoke the heartRateCalculator function. Pass the age and resting heart rate as arguments.
(c) In the heartRateCalculator function, write code to calculate target heart rate during fitness training with the following formula:
Target hart rate = (220 – age – resting heart rate) * 0.4 + resting heart rate
Display target heart rate.
(d) Don’t forget to write the necessary function prototype statement.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include <cstdlib>
#include <iostream>
using namespace std;
void heartRateCalculator (double,double);
int main()
{
	double age = 0.0;
	double restingHeartRate = 0.0;
	double heartRateCalculator = 0.0;
	double TargetHeartRate= 0.0;
	
	cout << "Please enter your age:";
	cin >> age;
	cout << "What is your resting heart rate?:";
	cin >> restingHeartRate;
	heartRateCalculator (age,restingHeartRate);
  
	
	system("pause");
    return 0;
}

void heartRateCalculator (double age,double restingHeartRate)
{
	double heartRateCalculator = 0.0;
	
	TargetHeartRate = (220-age-restingHeartrate)*0.4 + restingHeartRate;
	cout << "Target Heart Rate:" << TargetHeartRate <<endl;
	
}
1. dont use same name for function and variable
2. TargetHeartRate in heartRateCalculator() has to be declared.
3. have to be careful with case sensitive variables
Topic archived. No new replies allowed.