Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. bool targetHeartRate(int age, int beats)
  6. {
  7.     double minRate = (220 - age)*0.6;
  8.     double maxRate = (220 - age)*0.7;
  9.  
  10.     if (beats >= minRate && beats <= maxRate)
  11.         return true;
  12.     else
  13.         return false;
  14.  
  15. }
  16.  
  17. void main12()
  18. {
  19.     int age, beats;
  20.  
  21.     cout << "Enter your age: ";
  22.     cin >> age;
  23.     while (age < 0)
  24.     {
  25.         cout << "Enter a valid age: ";
  26.         cin >> age;
  27.     }
  28.  
  29.     cout << "Check and answer your beat per minute: ";
  30.     cin >> beats;
  31.  
  32.     bool check = targetHeartRate(age, beats);
  33.  
  34.     if (check)
  35.         cout << "You are in your target heartrate" << endl;
  36.     else if (!check)
  37.         cout << "Your are outside your target heartrate" << endl;
  38.  
  39.     system("pause");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement