—▢✕
doomsday.cpp — doomsday — Visual Studio Code
—▢✕
C++ doomsday.cpp ×︎
1#include <iostream>2using namespace std;34int DAY, MONTH, YEAR;5int tempyear;6int incorrect;7int leapyear;8int anchorday;9// int daysinmonth = 31;10int base;11int temp;12int sum;13string month;14string day;1516void tellDay(int date) {17 date %=7;18 switch (date){19 case 1:20 day = "Monday";21 break;22 case 2:23 day = "Tuesday";24 break;25 case 3:26 day = "Wednesday";27 break;28 case 4:29 day = "Thursday";30 break;31 case 5:32 day = "Friday";33 break;34 case 6:35 day = "Saturday";36 break;37 default: 38 day = "Sunday";39 break;40 }41 cout << day << endl;42}4344int main () {45 incorrect = 0;46 leapyear = 0;4748 cout<<"Welcome To Doomsday Date Machine\n\n";49 cout<<"Choose any date using the Doomsday Algorithm\n";50 cout<<"This Machine will tell you the Day of the Week\n\n";5152 cout<<"Tell me Year: ";53 54 cin >> YEAR;55 // cout << YEAR;5657 // int chckyearnleap () { // checked58 // if corect year / non negtive59 if (YEAR < 0){60 incorrect = 1;61 cout<<"\nNegative years not allowed, since it only works for gegrian calender\n";62 }6364 else if(((YEAR%4 == 0) && (YEAR%400 == 0)) || ((YEAR%4 == 0) && (YEAR%100 != 0))){65 cout<<"\nWow its a Leap year\n";66 leapyear = 1;67 }6869 // int findanchor () { //checked70 //base 2000 tuesday SFWT->71 base = 2;72 tempyear = YEAR;// 190073 tempyear /= 100; // 1974 temp = tempyear - 20; // -175 temp %= 4;// -176 // if -ve77 if (temp<0){78 temp += 4;// 379 }80 // if +ve81 if (temp == 3)82 base = 3; //383 else if (temp == 2)84 base = 5;85 else if (temp == 1)86 base = 0;//87 //base done // 88 cout << "\nCentury Anchor/start will be a : ";89 tellDay(base);9091 cout<<"\nTell me Month: ";92 cin >> MONTH;93 // cout << MONTH;9495 // int finddoomsdydate () {// checked , ps: change anchor anchorday name96 anchorday = 12;97 switch (MONTH){98 case 1:99 anchorday = 3;100 // daysinmonth = 31;101 if (leapyear){102 anchorday = 4;103 }104 month = "january";105 break;106 case 2:107 anchorday = 28;108 // daysinmonth = 28;109 if (leapyear){110 anchorday = 29;111 // daysinmonth = 29;112 }113 month = "feburary";114 break;115 case 3:116 anchorday = 14;117 // daysinmonth = 31;118 month = "march";119 break;120 case 4:121 anchorday = 4;122 // daysinmonth = 30;123 month = "april";124 break;125 case 5:126 anchorday = 9;127 // daysinmonth = 31;128 month = "may";129 break;130 case 6:131 anchorday = 6;132 // daysinmonth = 30;133 month = "june";134 break;135 case 7:136 anchorday = 11;137 // daysinmonth = 31;138 month = "july";139 break;140 case 8:141 anchorday = 8;142 // daysinmonth = 31;143 month = "august";144 break;145 case 9:146 anchorday = 5;147 // daysinmonth = 30;148 month = "september";149 break;150 case 10:151 anchorday = 10;152 // daysinmonth = 31;153 month = "october";154 break;155 case 11:156 anchorday = 7;157 // daysinmonth = 30;158 month = "november";159 break;160 default:161 // daysinmonth = 31;162 month = "december";163 }164 cout << "\nYoure choosen month is: "<<month << endl;165 cout<<"In this month the Doomsday is at: "<< anchorday << endl;166167 cout<<"\nTell me Day: ";168 cin >> DAY;169 // cout << DAY << endl;170171 // int dateincorrect () { // chck not in use currently172 if (incorrect){173 //#message174 cout << "\nIncorrect Date please try Again\n";175 }176 // }177178 //doomsdays // checked179 /*180 january 3-4 | 1/3-4181 feburary 28-29 | 2/28-29182 march - 14 | 3/14183 april - 4 | 4/4184 may - 9 | 5/9185 june - 6 | 6/6186 july - 11 | 7/11187 august - 8 | 8/8188 september - 5 | 9/5189 october - 10 | 10/10190 november - 7 | 11/7191 december - 12 | 12/12192 */193194 // doomsday();195 // int doomsday () { // checked , 2003 2000 1999196 // fingers197 // base198 // tempyear / 12199 // temp = tempyear % 12200 // temp / 4201202 sum = 0;203 tempyear = YEAR; // 2000204 tempyear %= 100; // 00 205206 temp = tempyear % 12; // 0207208 // cout << "\nBase = " << base << endl;209 sum += base; // 2210 // cout << "\nBase = " << base << endl;211 sum += tempyear / 12; // 0212 // cout << "\nBase = " << base << endl;213 sum += tempyear % 12; // 0214 // cout << "\nBase = " << base << endl;215 sum += temp / 4; // 0216 // cout << "\nBase = " << base << endl;217 // 218 sum %= 7; // 2219 // cout << "\nBase = " << base << endl;220221222 cout<< "\nDoomsday is at " << sum << "th day of the week -> ";223 tellDay(sum); 224225 // calculateDay();226 // int calculateDay () {227 //temp228 //sum -> day of doomsday229 //achorday -> date of doomsday 230 //DAY is date of which day is to be calculated231 temp = DAY - anchorday;232 temp %= 7;233234 if (temp < 0){235 temp += 7;236 }237 temp += sum;238 temp %= 7;239 // } 240241 // tellDay(temp);242243244 // cout<<"\n day = " << day << "\n";245 cout << "\nSo on Year " << YEAR << " / " ;246 cout << MONTH << " / " << DAY;247 cout<< "TH \nthe Day of the week is ";248 tellDay(temp); 249250 cout << endl; 251252 return 0;253254}
Problems
Output
Debug Console
Terminal
Ports
Jupyter
1×
⏻︎
⧉︎
🗑︎
booting the machine…