Create different versions of the program that: Calculates the user\'s age in min
ID: 3667395 • Letter: C
Question
Create different versions of the program that:
Calculates the user's age in minutes and seconds.
Estimates the approximate number of times the user's heart has beat in his/her lifetime using an average heart rate of 72 beats per minutes.
Estimates the number of times the person has sneezed in his/her lifetime (research on the Internet to obtain a daily estimate).
Estimates the number of calories that the person has expended in his/her lifetime (research on the Internet to obtain a daily estimate). Also calculate the number of sandwiches (or other common food item) that equals that number of calories.
Be creative: Pick other health-related statistic. Try searching the Internet to determine how to calculate that data, and create a program to perform that calculation. The program can ask the user to enter any information needed to perform the calculation.
Please use C language
Explanation / Answer
#include <iostream>
using namespace std;
/* This program computes the user s age in days from the input in years. This program also computes the user s age in minutes and seconds. This program also estimates the approximate number of times the user's heart rate has beat in his/her lifetime using an average heart rate. The program estimates the number of times the person has sneezed in his/her life time. The program also estimates the number of calories that the person has expended in his/her lifetime and the number of sandwiches that equals the number of calories.
*/
int main() {
int ageYears = 0; // The input of the users age in years
int ageDays = 0; // The users age in days
unsigned long ageMin = 0; // Users age in minutes
unsigned long ageSec = 0; // Users age in seconds
unsigned long heartRate = 0; // The heartrate of the user
int sneezeLifeTime = 0; // The number of times the user has sneezed in their lifetime
int calLifeTime = 0; // The number of calories that the user has accumulated over their lifetime.
int hamCheeseSand = 0; // The number of sandwiches that equal the number of calories of the user in lifetime.
cout << "Hello!" << endl;
cout << "How old are you?" << endl;
cin >> ageYears;
ageDays = ageYears * 365; // The computed input of the user age in days based on the users age in years.
cout << "Your age determined in days is approximately " << ageDays << " days." << endl;
ageMin = ageDays * 1440; // The computed input of the users age in minutes based on the number of days (multiply users age in days by 1440).
ageSec = (ageDays * 86400) % 60; // The computed input of the users age in seconds
cout << "Your age determined in minutes and seconds is " << ageMin << " minutes and " << ageSec << " seconds." << endl;
heartRate = ageMin * 72; //The computed heartrate of the user based on the users age (72 beats per min).
cout << "Your heartbeat that is accumulated over your lifetime is currently " << heartRate << " beats." << endl;
sneezeLifeTime = ageYears * 200; // The computed times the user have sneezed based on the input of the users age in years (200 sneezes per year on average).
cout << "The number of times you sneezed over your lifetime is currently " << sneezeLifeTime << " sneezes." << endl;
calLifeTime = ageDays * 2500; // The number of calories that the user has accumulated over their lifetime based on the users age in days (average intake of calories 2500).
cout << "The number of calories you have expended on your lifetime is " << calLifeTime << " calories." << endl;
hamCheeseSand = calLifeTime / 352; // The number of sandwiches that equal the number of calories the user has expended over their lifetime (352 calories for ham and cheese sandwich).
cout << "The number of sandwiches that you has expended on your lifetime based on the number of calories that you have consumed is " << hamCheeseSand << " sandwiches." << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.