Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++,input a month, day and a year, as in: 6 18 2014 Using the algorithm given in class, output the Day of the Week.

Using C++,input a month, day and a year, as in: 6 18 2014 Using the algorithm given in class, output the Day of the Week. You will need the following table corresponding to the 12 months. Jan 1 Feb 4 Mar 4 Apr 0 May 2 Jun 5 Jul 0 Aug 3 Sept 6 Oct 1 Nov 4 Dec 6 Pseudo-Code in English (sort of) read in the Month, Day, and a 4 digit Year convert the Month over to the table entry t = table entry + day + year + 6 t = t + year / 4 - year / 100 + year / 400 adjust t for January and February of a leap year compute the day of the week - dotw = t % 7; using dotw, print the day of the week Here is part of the program in English and a few statements in C++. #include  using namespace std; int main() { declarations of variables go here display directions to the user read in the month, day, and year if (month == 1) te = 1; etc - - t = te + Day + year + 6; t = t + year / 4 - year / 100 + year / 400; /* leap year adjustment */ if ((year % 400 == 0) && (month <= 2)) t = t - 1; else if (year % 100 == 0) {} /* not a leap year */ else if ((year % 4 == 0) && (month <= 2)) t = t - 1; dotw = the remainder after dividing t by 7 if (dotw == 0) cout << "Saturday" << endl; etc - - } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started