// Calculate Your Age and Check either today is your BIRTHDAY or not....
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int birth_date, birth_month, birth_year, current_date, current_month, current_year, age_date , privous_month_days;
int age_month, age_year;
char answer1, answer2;
/* --------------------------------------------- */
cout << "***++*** PLEASE ENTER VALID VALUES TO CALCULATE YOUR AGE ***++***\n"<<endl;
/* ---------------Current Date---------------- */
cout << "Plz Enter Current Date Step by Step....\n"<<endl;
cout << "Enter Current Date(Date only): ";
cin >> current_date;
if(current_date > 31 || current_date < 0)
{
cout<<"Plz enter Valid date" << endl;
exit(1);
}
cout << "Enter Current Month: ";
cin >> current_month;
if(current_month > 12 || current_month < 0)
{
cout<<"Plz enter Valid Month" << endl;
exit(1);
}
cout << "Enter Current Year: ";
cin >> current_year;
cout <<endl;
/* ---------------------Date Of Birth------------------- */
cout << "Plz Enter your Date of Birth Step by Step....\n"<<endl;
cout << "Enter your Birth Date (Date only): ";
cin >> birth_date;
if(birth_date > 31 || birth_date < 0)
{
cout<<"Plz enter Valid date" << endl;
exit(1);
}
cout << "Enter your Birth Month: ";
cin >> birth_month;
if(birth_month > 12 || birth_month < 0)
{
cout << "Plz Enter Valid Month." <<endl;
exit(1);
}
cout << "Enter your Birth year: ";
cin >> birth_year;
cout <<endl;
if(birth_year > current_year || birth_year < 0)
{
cout << "Plz Enter Correct Year Next Time!!!" <<endl;
exit(1);
}
/* ------------ Confirmation for Dates ------------- */
cout << "Current Date is : " << current_date << "-" << current_month << "-" << current_year <<endl;
cout << "Your Date of Birth is : " << birth_date << "-" << birth_month << "-" << birth_year <<endl;
/* -------------- Checking leap year ------------- */
cout << "NOTE: Either These Dates are correct or not??? # Y or N #: ";
cin >> answer1;
if (answer1=='Y' || answer1 == 'y')
{
if(current_year%4==0)
{
cout << "\nCurrent Year is Leap Year." <<endl;
}
else
{
cout << "\nCurrent Year is not Leap Year." <<endl;
}
cout <<endl;
/* --------------------------------------------- */
/* ------Calculation for Days------- */
if(current_date < birth_date)
{
cout << "Days of January= 31 \t Days of Febrary= 28 (if Current year is leap year then 29)"<<endl;
cout << "Days of March= 31 \t Days of April= 30 "<<endl;
cout << "Days of May= 31 \t Days of June= 30 "<<endl;
cout << "Days of July= 31 \t Days of August= 31 "<<endl;
cout << "Days of September= 30 \t Days of October= 31 "<<endl;
cout << "Days of November= 30 \t Days of December= 31 "<<endl;
cout<<endl;
cout << "Enter Days in Privous month with respect to your birth month: ";
cin >> privous_month_days;
current_date = current_date + privous_month_days;
current_month --;
age_date = current_date - birth_date;
}
else
{
age_date = current_date - birth_date;
}
cout <<endl;
if(current_month < birth_month)
{
current_month = current_month+12;
current_year --;
age_month= current_month - birth_month;
}
else
{
age_month= current_month - birth_month;
}
age_year = current_year - birth_year;
cout << "\n*** Your Age is: " << age_year << " Year(s), " << age_month << " Month(s) and " << age_date << " Day(s)." << endl;
if(birth_date==current_date && birth_month == current_month)
{
cout << "\n\nHappy BirthDay To You Dear. \n \t Happy Birth Day \n\t\t Happy Birth Day To you....."<<endl;
}
cout << "\n\nARE YOU AGREE WITH THIS CALCULATION??? ( Y or N ): ";
cin >> answer2;
if(answer2 == 'Y' || answer2 == 'y')
{
cout << "\nThank You So0Oo0O Much \t\t ALLAH HAFIZ."<< endl;
cout <<endl;
cout <<endl;
exit(1);
}
else if (answer2 == 'N' || answer2 == 'n')
{
cout << "Plz Enter Confirmed Dates.....!!!" <<endl;
exit(1);
}
else
{
cout << "You have Entered an invalid character which is consider as NO.....\n\t Plz Enter Correct Value Next Time!!"<<endl;
exit(1);
}
}
else if(answer1 == 'N' || answer1 == 'n')
{
cout << "Plz Enter Dates again Correctly...."<<endl;
exit(1);
}
else
{
cout << "You have Entered an invalid character which is consider as NO.....\n\t Good Bye!!"<<endl;
exit(1);
}
/* --------------------------------------------- */
return 0;
}
No comments:
Post a Comment