1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
//Homework 4
//Days of Our Lives
//Given a birthdate how many days has the user been alive, how many
// days until their next birthday, how many days until 87
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
enum MONTHS {JAN=1, FEB, MAR, APR, MAY, JUUN, JUL, AUG, SEPT, NOV, DEC};
int Current_Date(int current_month, int current_day, int current_year);
int Days_Alive(int month, int day, int year, int current_month, int current_day, int current_year,
int birth_year, int birth_month, int birth_day);
bool isLeap(int year);
int daysTilNextBday( int birth_day, int birth_month, int current_day, int current_month, int current_year, int year);
int daysInMonth(int month, int year);
int get_Birthday(int birth_month, int birth_day, int birth_year);
int daysInYear(int year);
int thisYear(int current_year);
int thisDay(int current_day);
int thisMonth(int current_month);
int bDay(int birth_day);
int bMonth(int birth_month);
int bYear(int birth_year);
char menu_choice;
char MainMenu(char shape_choice);
char Table_of_Contents();
int main()
{
int month, day, year, current_month, current_day, current_year, birth_day, birth_month, birth_year, end_month, end_day, end_year;
char exit;
cout << "Hello! Welcome to The Days of Our Lives Age Calculator!" << endl << endl;
cout << "Using your birthday, this program can perform several calculations." << endl << endl << endl;
cout << "Please choose from the following menu: " << endl << endl;
cout << "To calculate how many days you have been alive, enter 'D'." << endl << endl;
cout << "To calculate how many days until your next birthday, enter 'N'." << endl << endl;
cout << "To calculate how many days until you reach four score and seven years (87 years old), enter 'F'." << endl << endl;
cout << "To quit this program, enter 'Q'." << endl << endl;
cin << menu_choice;
return (menu_choice);
do
{
exit = MainMenu(Table_of_Contents());
}
while((exit!= 'Q')&&(exit!='q'));
system("PAUSE");
return EXIT_SUCCESS;
system("PAUSE");
return EXIT_SUCCESS;
}
char MainMenu(char menu_choice)
{
switch (menu_choice)
{
case 'D':
case 'd':
cout << "You chose to calculate how many days you've been alive." << int Days_Alive(int month, int day, int year, int current_month, int current_day, int current_year,
int birth_month, int birth_year, int birth_day);
cout << endl << endl;
break;
case 'N':
case 'n':
cout << "You chose to calculate how many days until your next birthday." << int daysTilNextBday(int birth_day, int birth_month, int birth_year, int current_day, int current_month, int current_year, int year);
cout << endl << endl;
break;
case 'F':
case 'f':
cout << "You chose to calculate how many days until you are four score and seven years old (87)." << AreaRectangle(get_length(), get_width());
cout << endl << endl;
break;
int get_Birthday(int birth_month, int birth_day, int birth_year){
cout << "Please enter your Birthday. Use (1-12) for the months." << endl;
int bMonth(int birth_month);
cout << "month: " << endl;
int bDay(int birth_day);
cout << "day: " << endl;
int bYear(int birth_year);
cout << "year: " << endl;
cout << "Your Birthday is: "<<birth_month<< " /"<<birth_day;
cout << " / " << birth_year << endl << endl;
}
int Current_Date(int& current_month, int& current_day, int& current_year){
cout << "Please enter today's date." << endl;
int thisMonth(int current_month);
int thisDay(int current_day);
int thisYear(int current_year);
cout << "The Current Date is: "<< current_month << " /"<< current_day;
cout << " / " << current_year << endl << endl;
}
bool divisibleBy( int number, int divisor){
return number % divisor == 0;
}
bool isLeap(int year) {
bool leap(false);
if (divisibleBy( year, 4) ){
if(divisibleBy( year, 100)){
if (divisibleBy( year, 400))
leap = true;
else
leap = false;
}
else
leap = true;
}
else
leap = false;
return leap;
}
int daysInFebruary(int year){
int result(28);
if ( isLeap(year))
result = 29;
return result;
}
/*int Days_in_Month(int month, int year)
{
if(9==month || 4==month || 6==month || 11==month)
{
return 30;
}
else if (2==month)
{
if(is_Leap())
return 29;
else
return 28;
}
else
{
return 31;
}
}*/
|