THIS PROGRAM SHOULD BE IN C++ Part One Write a program that takes in number of m
ID: 1715307 • Letter: T
Question
THIS PROGRAM SHOULD BE IN C++
Part One
Write a program that takes in number of minutes and expresses that in terms of Hours and minutes. For example: If the user inputs 90, the output of your code must be 1 hour and 30 minutes. (Use the % operator.)
Part Two
Write a program that takes in the user’s age in years as input:
Calculate the user’s age in days
Calculate the user’s age in minutes and seconds
Estimate 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.
Estimate the number of times the person has sneezed in his/her lifetime(research on the Internet to obtain a daily estimate).
Estimate the number of calories that the person has expended in his/her lifetime (research on the Internet to obtain a daily estimate).
Both parts will be written in the same program and compiled and output together.
#include <iostream>
using namespace std;
int main() {
cout << " hour and " " seconds." //convert minutes into hours and minutes
cout << "The user has lived" //output users age in days ( no-leap years)
cout << "The user has lived" //output users age in minutes ( no-leap years)
cout << "The user has lived" //output users age in seconds ( no-leap years)
cout << "The user's heart has beat " " times in their lifetime." // heart beats in lifetime
cout << "The user has sneezed " " in their lifetime."<< endl; // sneezes in lifetime
cout << "The user has burned " " calories in their lifetime."<< endl; // calories burned in lifetime
return 0;
}
Explanation / Answer
PART-1 : Program that takes in number of minutes and expresses that in terms of Hours and minutes:
#include <iostream>
using namespace std;
#define SECS_PER_MIN 60
#define SECS_PER_HOUR 3600
void main(void)
{
unsigned int seconds, minutes, hours, secs_left, mins_left;
cout<<"Enter number of seconds: ";
cin>>seconds;
hours = seconds / SECS_PER_HOUR;
minutes = seconds / SECS_PER_MIN;
mins_left = minutes % SECS_PER_MIN;
secs_left = seconds % SECS_PER_MIN;
cout<<seconds<<" seconds is equal to "<<hours<<" hours, "<<mins_left<<" minutes, "<<secs_left<<" seconds"<<endl;
return;
}
PAR-2: Program on user’s age in days
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.