Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program (in C++) that inputs a date (for example, July 4, 2008) and outp

ID: 3570073 • Letter: W

Question

Write a program (in C++) that inputs a date (for example, July 4, 2008) and outputs the day of the week that corresponds to that date. The following algorithm is from http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week. The implementation will require several functions.

            bool isLeapYear(int year);

This function should return true if year is a leap year and false if it is not. Here is pseudocode to determine a leap year:

            Leap_year = (year divisible by 400) or (year divisible by 4 and year not divisible by 100))

            Int getCenturyValue(int year);

This function should take the first two digits of the year (that is, the century), divide by 4, and save the remainder. Subtract the remainder from 3 and return this value multiplied by 2. For example, the year 2008 becomes: (20/4)=5 with a remainder of 0. 3-0=3. Return 3*2=6.

            Int getYearValue(int year);

This function computes a value based on the years since the beginning of the century. First, extract the last two digits of the year. For example, 08 is extracted for 2008. Next, factor in leap years. Divide the value from the previous step by 4 and discard the remainder. Add the two results together and return this value. For example, from 2008 we extract 08. Then (8/4)=2 with a remainder of 0. 2+8=10.

            Int getMonthValue(int month, int year);

This function should return a value based on the table and will require invoking the isLeapYear function:

            Month                         Return Value

            January                        0 (6 if year is a leap year)

            Feb                              3 (2 if year is a leap year)

            March                          3

            April                            6

            May                             1

            June                             4

            July                              6

            August                                    2

            September                   5

            October                       0

            November                   3

            December                    5

Finally, to compute the day of the week, compute the sum of the date

Explanation / Answer

#include #include #include using namespace std; // declaring int Day = 0; int Month = 0; int Year = 0; bool leapYear (int); int main(int argc, char *argv[]) { // outputting messages to the user cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote