Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that today is Monday, we want the user to entre a number N and guess what would be the weekday after N days, then

Suppose that today is Monday, we want the user to entre a number N and guess what would be the weekday after N days, then your program will check whether the users guess is correct or wrong and display a message accordingly.
e.g. Suppose today is Monday, if the user enters 8 for N and Friday for the guessed weekday, meaning that 8 days after today it will be a Friday. Your program should find out that the user's guess is wrong and display a message. See below examples of input/output.
Notes:
Use the assert function to make sure that the number of days entered by the user is positive.
Use the modulo operator and a switch statement to find the weekday.
e.g. if today is Monday, then after 8 days the weekday is Tuesday as 8%7 = 1: the 1st day following Monday is Tuesday. After 10 days the weekday is Thursday as 10%7 =3: the 3rd day following Monday is Thursday. After 41 days the weekday is Sunday as 41%7=6: the 6th day following Monday is Sunday. etc.
Include the cstring.h header file to be able to use the type string: #include.
Declare the 7 weekdays as constants of type string.
e.g. const string TODAY = Monday ;
const string Wed = Wednesday ;
const string wed = wednesday ;
Your program should consider weekdays with uppercase first letter or lowercase first letter.
e.g. given the above two constants Wed and wed, if weekDay is the name of the variable containing the weekday entered by the user, then you can make this test:
if(weekDay != Wed && weekDay != wed)
to check that the user input is neither equal to Wednesday, nor equal to wednesday.
Challenge [will not be graded]: Suppose all the months have 30 days, can you modify your program to guess in which weekday you were born.
Examples of input/output:
Enter a positive number of days : 8
Enter a week day : saturday
You guessed the wrong weekday.
Today is Monday. So, after 8 days, it will be Tuesday
Enter a positive number of days : 10
Enter a week day : wednesday
You guessed the wrong weekday.
Today is Monday. So, after 10 days, it will be Thursday
Enter a positive number of days : 41
Enter a week day : Sunday
You guessed the correct weekday.
Effectively, as today is Monday after 41 days, it will be Sunday
write a program c++

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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

Describe the four specific guidelines for using the direct plan.

Answered: 1 week ago