Question: /* this is file Year X.cpp You are working with a coding partner. He is halfway finished with this program. He also left many comments

/* this is file Year X.cpp

You are working with a coding partner. He is halfway finished with this program.

He also left many comments for you to complete the program.

Here is what we know:

1. The program is called Year X. This year is Year X.

2. This program gets input of month and day and then prints the weekday of the given input.

3. This program first prints out the case for April 15.

4. It is known that January 1st of Year X is Monday.

5. It is known that Febuary of the Year X has 28 days.

6. All variables are already defined, so you cannot add more variables except the loop control variables.

7. You cannot change the existing lines of codes or comments. You are allowed to add codes and add comments.

*/

#include

#include

using namespace std;

int main() {

// init

string months[] = { "Jan", "Feb", "Mar", "Apr", "May","Jun","Jul", "Aug", "Sep","Oct", "Nov", "Dec" };

string weekdays[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };

const int daysPerWeek = 7;

const int monthPerYear = 12;

// Year X

string dayOne = "Mon";

int dayOneNum = 1;

int monthDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

//section 1: take care the case of April 15

int theDay = 15, theMonth = 4, days, theWeekDay;

days = monthDays[1 - 1] + monthDays[2 - 1] + monthDays[3 - 1] + theDay;

theWeekDay = days % daysPerWeek;

cout << "Apr 15 is ";

switch (theWeekDay) {

// task 1: please print the corresponding weekday using the weekdays array from Monday to Sunday

}

// the end of task 1

// Section 2: take care of the user input month and day

string inMonth;

int inDay;

// prompt the user for input month and day

// task 2: check the input month is legitimate

// please provide the code for this part

// input

cout << "Please input the Month of your choice:" << endl;

cin >> inMonth;

// the end of task2

// task 3: check the input day is legitimate

// please provide the code for this part

cout << "Please input the day of your choice" << endl;

cin >> inDay;

// the end of task 3

cout << inMonth << " " << inDay << " is ";

// task 4: please find out the weekday and print it out

// follow the sample output in the April 15 example.

// print out the input month and day is which weekday

// the end of task 4

return 0;

}

Can anyone teach me how to solve task 1, task 2 , task 3 and task 4?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!