#include <iostream>
const long long heart_rate_per_minute = 72;
const int minutes_in_hour = 60;
const int hours_in_day = 24;
const int days_in_year = 365;
int main() {
using std::cout;
cout << "Hello user! Please enter your age to see how many beats your heart has made: ";
int age = 0;
while (!(std::cin >> age) || age <= 0) {
std::cin.clear();
while (!isspace(std::cin.get()))
continue; // get rid of bad input
std::cout << "Invalid input! Please repeat: ";
}
unsigned long long heart_beats = heart_rate_per_minute * minutes_in_hour * hours_in_day * days_in_year;
heart_beats *= age;
cout << "Wow! Unbelievable! Your heart has beaten " << heart_beats << " times already! Isn't it awesome?" << std::endl;
return 0;
}
Comments
Leave a comment