Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
78 lines (66 loc) · 2.73 KB
/
Copy pathmain.cpp
File metadata and controls
78 lines (66 loc) · 2.73 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "HeartRates.h"
int main() {
string firstName, lastName, birthMonth, currentMonth;
int birthDay, birthYear, currentDay, currentYear;
int maxHeartRate, lowerEnd, upperEnd;
char choice;
int count = 3;
while (count > 0) {
cout << "\n+--------------------------------+" << endl;
cout << "| TARGET-HEART-RATE CALCULATOR |" << endl;
cout << "+--------------------------------+" << endl;
cout << "(You can run this program up to " << count << " more times.)" << endl;
cout << "Enter first name: ";
cin >> firstName;
cout << "Enter last name: ";
cin >> lastName;
do {
cout << "Enter birth month: ";
cin >> birthMonth;
}
while (!HeartRates::isValidMonth(birthMonth));
do {
cout << "Enter birth day (1-31): ";
cin >> birthDay;
}
while (!HeartRates::isValidDay(birthMonth, birthDay));
cout << "Enter birth year: ";
cin >> birthYear;
do {
cout << "Enter current month: ";
cin >> currentMonth;
}
while (!HeartRates::isValidMonth(currentMonth));
do {
cout << "Enter current day (1-31): ";
cin >> currentDay;
}
while (!HeartRates::isValidDay(currentMonth, currentDay));
cout << "Enter current year: ";
cin >> currentYear;
HeartRates person(firstName, lastName, birthMonth, birthDay, birthYear);
int age = person.getAge(currentYear, currentMonth, currentDay);
maxHeartRate = person.getMaximumHeartRate(age);
person.getTargetHeartRate(maxHeartRate, lowerEnd, upperEnd);
cout << endl << "-- Heart Rate Information ---" << endl;
cout << "Name: " << person.getFirstName() << " " << person.getLastName() << endl;
cout << "Date of Birth: " << person.getBirthMonth() << " " << person.getBirthDay() << ", " << person.getBirthYear() << endl;
cout << "Age: " << age << " years old" << endl;
cout << "Maximum Heart Rate: " << maxHeartRate << " bpm" << endl;
cout << "Target Heart Rate Range: " << lowerEnd << " - " << upperEnd << " bpm" << endl;
cout << "Would you like to calculate for another person? (y/n): ";
cin >> choice;
if (choice == 'y' || choice == 'Y') {
count--;
} else {
break;
}
}
if(count == 0) {
cout << "You have reached the maximum number of calculations." << endl;
cout << "Please restart the program to calculate again." << endl;
} else {
cout << "Thank you for using the Target Heart Rate Calculator!" << endl;
}
return 0;
}