Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that accepts two values from the user. These numbers represe

ID: 3641933 • Letter: W

Question

Write a C++ program that accepts two values from the user. These numbers represent the month and day of a date. (1, 2 would be January 2nd). Write a function that prints the two values in the following format (1:2) OR throws exceptions if the data is out of range. (The month should be from 1 to 12 and the day should be from 1 to 31). Your exception should tell the user what mistake they made in entering the data. (Month too small, month too large, day too small, day too large).

Have this program loop until an EOD date is entered. You choose the EOD, just be sure to tell the user what the EOD is.

Explanation / Answer

The easiest way to do this is is not the quickest but you can improve the algorithm after it works. start with the input cmds and create two variables to store them. (i create variables as needed) then create an if/else chain that looks at the month. there should be 13 links with the last one being the invalid input response inside of the month elses specifically you should check to see that the day is in the valid range for that month. i recommend having a flag (simple true/false variable) that is initially set to true and once something fails it changes the flag to false. after checking that the input is valid or not the flag should determine if the output is 'error; invalid input' or if you should work to interpret the data. should it be true just set up the same if/else chain and have it output the correct month and day since you know the data is correct. simply i see this with 3 variables, two input variables, and two if/ else chains...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote