Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using c++ sample program Question 1 We are in the month of February, we want the user to enter a number N and guess which

using c++
sample program image text in transcribed
image text in transcribed
image text in transcribed
Question 1 We are in the month of February, we want the user to enter a number N and guess which month it will be in N months, then your program will check whether the user's guess is correct or wrong and display a message accordingly. e.g. Since if we are in February, if the user enters 8 for N and April for the guessed month, meaning that 8 months from now, it will be April. 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 months entered by the user is positive. - Use the modulo operator and a switch statement to find the correct month. - e.g. if we are in February, then after 8 months the month will be October as (2+8)%12=10: the 8th month following February is October. After 11 months from February as (2+11)%12=1 : The 11 th Month from February is January. After 41 months from February, the month is July as (2+41)%12=7 - Include the header file to be able to use the type string: \#include. - Declare the 12 months as constants of type string. e.g. const string This_month = "February" ; const string Jan= "January" ; const string jan = "January" ; - Your program should consider months with uppercase first letter or lowercase first letter. e.g. given the above two constants Jan and jan, if guessedMonth is the name of the variable containing the guessed month entered by the user, then you can make this test: if(guessedMonth == Jan || guessedMonth == jan) to check that the user input is "January" or "january" Enter a positive number of months : 8 Enter a month : September You guessed the wrong month. We are in February. So, after 8 months, it will be October Enter a positive number of months : 11 Enter a month : march You guessed the wrong month. We are in February. So, after 11 months, it will be January Enter a positive number of months : 41 Enter a month : july You guessed the correct month. Effectively, as we are in February after 41 months, it will be July

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_2

Step: 3

blur-text-image_3

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

Let F be the distribution function F(x) = xn 0 Answered: 1 week ago

Answered: 1 week ago

Question

What are some metrics for evaluating recruitment and selection?

Answered: 1 week ago

Question

Explain Coulomb's law with an example

Answered: 1 week ago

Question

What is operating system?

Answered: 1 week ago

Question

What is Ohm's law and also tell about Snell's law?

Answered: 1 week ago