Chapter+3_Ex+3.12

Chapter 3 Exercise 12: Write a program that calculates the number of hours of your life that you have spent sleeping. Assume thut you sleep 8 hours each night. To simplify the problem, assume that there ar6 always 30 days in each month, and 365 days in each year. The program output should look similar to:

Enter your birthdate (using numbers for months): Month: 9 Dayi z t Year: l-984 Enter today's date (using numbers for months): Month: l-0 Day:26 Year z 2002 You have been alive for 6599 daYs. You have slept 52192 hours.

code format="cpp" using namespace std; int alive_count(int birthm, int birthd, int birthy, int todaym, int todayd, int todayy); int main(int argc, char *argv[]) {   int bmonth,bday,byear; int tmonth,tday,tyear; cout<<"Enter your birthdate (using numbers of months): "; cout<>bmonth; cout<>bday; cout<>byear; cout<<"Enter today's date (using numbers for months): "; cout<>tmonth; cout<>tday; cout<>tyear; int total_alive; total_alive = alive_count(bmonth, bday, byear, tmonth, tday, tyear); cout<<"You have been alive for: "<<total_alive; newline; cout<<"You have slept: "<<total_alive*8<<" hours"; cin.ignore(100,'\n'); cin.get; system("PAUSE"); return EXIT_SUCCESS; }
 * 1) include
 * 2) include
 * 3) define newline cout<<endl

int alive_count(int birthm, int birthd, int birthy, int todaym, int todayd, int todayy){ int total; total = (todayy-birthy)*365+(todaym-birthm)*30+(todayd-birthd); return total; }

code