Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <windows.h>
- using namespace std;
- class timecalcs {
- public:
- void agecalculator(){
- int year;
- int month;
- int day;
- cout << "What is the current year?" << endl;
- cin >> year;
- cout << "What is the current month?" << endl;
- cin >> month;
- cout << "What is the current day?" << endl;
- cin >> day;
- cout << "Your current year is: ";
- cout << year;
- cout << "/";
- cout << month;
- cout << "/";
- cout << day << endl << endl;
- int bornyear;
- int bornmonth;
- int bornday;
- cout << "What year were you born in?" << endl;
- cin >> bornyear;
- cout << "What month were you born in?" << endl;
- cin >> bornmonth;
- cout << "What day were you born in?" << endl;
- cin >> bornday;
- cout << "The date you were born is: ";
- cout << bornyear;
- cout << "/";
- cout << bornmonth;
- cout << "/";
- cout << bornday << endl;
- //FUNCTIONS
- int numyear = 365;
- int numday = 1;
- int numjan = 31;
- int numfeb = 28;
- int nummar = 31;
- int numapr = 30;
- int nummaj = 31;
- int numjun = 30;
- int numjul = 31;
- int numaug = 31;
- int numsep = 30;
- int numoct = 31;
- int numnov = 30;
- int numdec = 31;
- int daycurrent;
- int dayborn;
- int dayremaincalc;
- //daysumvv
- daycurrent = day;
- if (month == 1)
- {
- daycurrent = daycurrent + numjan;
- }
- if (month == 2)
- {
- daycurrent = daycurrent + numjan + numfeb;
- }
- if (month == 3)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar;
- }
- if (month == 4)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr;
- }
- if (month == 5)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj;
- }
- if (month == 6)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun;
- }
- if (month == 7)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul;
- }
- if (month == 8)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug;
- }
- if (month == 9)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep;
- }
- if (month == 10)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct;
- }
- if (month == 11)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov;
- }
- if (month == 12)
- {
- daycurrent = daycurrent + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov + numdec;
- }
- daycurrent = daycurrent + (year * numyear);
- dayborn = bornday;
- if (bornmonth == 1)
- {
- dayborn = dayborn + numjan;
- dayremaincalc = numjan;
- }
- if (bornmonth == 2)
- {
- dayborn = dayborn + numjan + numfeb;
- dayremaincalc = numfeb;
- }
- if (bornmonth == 3)
- {
- dayborn = dayborn + numjan + numfeb + nummar;
- dayremaincalc = nummar;
- }
- if (bornmonth == 4)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr;
- dayremaincalc = numapr;
- }
- if (bornmonth == 5)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj;
- dayremaincalc = nummaj;
- }
- if (bornmonth == 6)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun;
- dayremaincalc = numjun;
- }
- if (bornmonth == 7)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul;
- dayremaincalc = numjul;
- }
- if (bornmonth == 8)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug;
- dayremaincalc = numaug;
- }
- if (bornmonth == 9)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep;
- dayremaincalc = numsep;
- }
- if (bornmonth == 10)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct;
- dayremaincalc = numoct;
- }
- if (bornmonth == 11)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov;
- dayremaincalc = numnov;
- }
- if (bornmonth == 12)
- {
- dayborn = dayborn + numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov + numdec;
- dayremaincalc = numdec;
- }
- dayborn = dayborn + (bornyear * numyear);
- //daysum ^^
- //daycurrent = days from 0 to now.
- //dayborn = days from 0 to birthdate
- //now subtraction and convertion
- int bornsum = daycurrent - dayborn;
- int bornsumcopy = daycurrent - dayborn;
- int yeargive;
- int monthgive;
- monthgive = 0;
- if (bornsum >= 365)
- {
- yeargive = 1;
- bornsum = bornsum - 365;
- }
- if (bornsum >= 365)
- {
- yeargive = yeargive + 1 * ((bornsumcopy / 365) - 1);
- bornsum = bornsum - 365 * ((bornsumcopy / 365) - 1);
- }
- if (bornsum >= 365){
- yeargive = yeargive + 1;
- bornsum = bornsum - 365;
- }
- if (bornsum >= 365){
- yeargive = yeargive + 1;
- bornsum = bornsum - 365;
- }
- if (numfeb + numjan > bornsum && bornsum > numjan)
- {
- bornsum = bornsum - numjan;
- monthgive = 1;
- }
- if (nummar + numfeb + numjan > bornsum && bornsum > numjan + numfeb)
- {
- bornsum = bornsum - numjan - numfeb;
- monthgive = 2;
- }
- if ((nummar + numfeb + numjan + numapr) > bornsum && bornsum > nummar + numfeb + numjan)
- {
- bornsum = bornsum - numjan - numfeb - nummar;
- monthgive = 3;
- }
- if (nummar + numfeb + numjan + numapr + nummaj > bornsum && bornsum > numjan + numfeb + nummar + numapr)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr;
- monthgive = 4;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj;
- monthgive = 5;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun;
- monthgive = 6;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul + numaug > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun + numjul)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun - numjul;
- monthgive = 7;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul + numaug + numsep > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun - numjul - numaug;
- monthgive = 8;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul + numaug + numsep + numoct > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun - numjul - numaug - numsep;
- monthgive = 9;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun - numjul - numaug - numsep - numoct;
- monthgive = 10;
- }
- if (nummar + numfeb + numjan + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov + numdec > bornsum && bornsum > numjan + numfeb + nummar + numapr + nummaj + numjun + numjul + numaug + numsep + numoct + numnov)
- {
- bornsum = bornsum - numjan - numfeb - nummar - numapr - nummaj - numjun - numjul - numaug - numsep - numoct - numnov;
- monthgive = 11;
- }
- int daysleft;
- int monthsleft;
- int nextage;
- monthsleft = ((monthgive - 12) * (-1)) - 1;
- daysleft = dayremaincalc - bornsum ;
- nextage = yeargive + 1;
- cout << "You are: " << yeargive << ", " << monthgive << " months and " << bornsum << " days" << endl;
- cout << "Theres ";
- cout << monthsleft;
- cout << " months and ";
- cout << daysleft;
- cout << " days before your next birthday where you will be " << nextage << endl;
- cout << "This code was written by Valde" << endl << endl;
- Sleep(100);
- int menuagecalc;
- cout << "1 for agecalculator. \n2 for current year calculator. \n3 for birthdat calculator.\nEnter another number to exit.\n\nEnter your choice here: ";
- cin >> menuagecalc;
- cout << "" << endl;
- if (3 >= menuagecalc && menuagecalc >= 1) {
- if (menuagecalc == 1){
- timecalcs timcalcobject;
- timcalcobject.agecalculator();
- }
- if (menuagecalc == 2){
- timecalcs timcalcobject;
- timcalcobject.currentyearcalculator();
- }
- if (menuagecalc == 3){
- timecalcs timcalcobject;
- timcalcobject.birthdatecalculator();
- }
- }
- else {
- cout << "Exiting." << endl;
- exit(0);
- }
- }
- void currentyearcalculator(){
- int birthyear;
- int currentageyear;
- int year;
- int birthdayyet;
- cout << "What year were you born?" << endl;
- cin >> birthyear;
- cout << "\nWhat is your current age?" << endl;
- cin >> currentageyear;
- cout << "\nHave you had your birthday this year? 1/2 (1=yes, 2=no)" << endl;
- cin >> birthdayyet;
- year = currentageyear + birthyear;
- if (birthdayyet == 2)
- {
- year = year + 1;
- }
- cout << "\n\nThe current year is either " << year << " or one year more." << endl;
- }
- void birthdatecalculator(){
- int currentyear;
- int currentmonth;
- int currentday;
- int myageyear;
- int myagemonth;
- int myageday;
- cout << "What is the current year?" << endl;
- cin >> currentyear;
- cout << "\n\nWhat is the current month?" << endl;
- cin >> currentmonth;
- cout << "\n\nWhat is the current day?" << endl;
- cin >> currentday;
- cout << "\n\nWhat is your current age in years?" << endl;
- cin >> myageyear;
- cout << "\n\nHow many months into your age?" << endl;
- cin >> myagemonth;
- cout << "\n\nHow many days into your age, don't wright months." << endl;
- cin >> myageday;
- int resultday;
- int resultmonth;
- int resultyear;
- resultday = currentday - myageday;
- resultmonth = currentmonth - myagemonth;
- resultyear = currentyear - myageyear;
- if (resultday < 0)
- {
- resultmonth = resultmonth + 1;
- resultday = resultday + 30;
- }
- if (resultmonth < 0)
- {
- resultyear = resultyear + 1;
- resultmonth = resultmonth + 12;
- }
- cout << "This is the date you were born aprox: " << resultyear << "/" << resultmonth << "/" << resultday << endl;
- }
- };
- int menue()
- {
- int menu;
- cout << "1 for agecalculator. \n2 for current year calculator. \n3 for birthdat calculator.\nEnter another number to exit.\n\nEnter your choice here: ";
- cin >> menu;
- cout << "" << endl;
- if (3 >= menu && menu >= 1) {
- if (menu == 1){
- timecalcs timcalcobject;
- timcalcobject.agecalculator();
- }
- if (menu == 2){
- timecalcs timcalcobject;
- timcalcobject.currentyearcalculator();
- }
- if (menu == 3){
- timecalcs timcalcobject;
- timcalcobject.birthdatecalculator();
- }
- }
- else {
- cout << "Exiting." << endl;
- exit(0);
- }
- system("pause");
- return 0;
- }
- int main()
- {
- menue();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement