Question
Along with this document you were emailed proj1_P2.cpp. You are to complete the implementation of the method DayOfWeek such that the program works properly. You
Along with this document you were emailed proj1_P2.cpp. You are to complete the implementation of the method DayOfWeek such that the program works properly. You are required to use a switch statement in the method DayOfWeek Once complete email back proj1_P2.cpp DO NOT change any code in the main code block. Output from your completed program should look like this:
Enter an integer number between 1 - 7, for day of week
2
The day of week you picked is Monday
Do you want to continue y/n
y
Enter an integer number between 1 - 7, for day of week
7
The day of week you picked is Saturday
Do you want to continue y/n
y
Enter an integer number between 1 - 7, for day of week
1
The day of week you picked is Sunday
Do you want to continue y/n
y
Enter an integer number between 1 - 7, for day of week
66
The day of week you picked is Illegal weekday
Do you want to continue y/n
Here is the code block needed to complete the problem:
#include#include using namespace std; // Student should add a function prototype block here string DayOfWeek(int day); int main() { int dayNumber; bool looping = true; while (looping) { cout << "Enter an integer number between 1 - 7 for a day of week" << endl; cin >> dayNumber; cout << "The day of the week you picked is : " << DayOfWeek(dayNumber) << endl; string answer; cout << "Do you want to continue y / n" << endl; cin >> answer; if ((answer.compare("n") == 0) || (answer.compare("N") == 0)) { looping = false; } } return 0; } ///////////////////////////////////////////////////////////////////////////////////////// // // Student needs to supply correct implementation for this method using a switch statement // //////////////////////////////////////////////////////////////////////////////////////////// string DayOfWeek(int day) { string aDay = "Sunday"; return aDay; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started