Question: Write a program that allows a user to enter a string containing a day of the week (Sunday, Monday, Tuesday, etc.) and uses a

Write a program that allows a user to enter a string containing a day of the week ("Sunday," Monday," "Tuesday," etc.) and uses a 

Write a program that allows a user to enter a string containing a day of the week ("Sunday," Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20 Write a program that allows a user to enter a string containing a day of the week ("Sunday," Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20

Step by Step Solution

3.47 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

TestCodem day inputEnter day of week s switch day case Sund... View full answer

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 Mechanical Engineering Questions!