If necessary, create a new project named Advanced26 Project and save it in the Cpp8Chap11 folder. Also
Question:
If necessary, create a new project named Advanced26 Project and save it in the Cpp8\Chap11 folder. Also create a new source file named Advanced26.cpp. Declare a 12-element int array named days. Assign the number of days in each month to the array, using 28 for February. Code the program so that it displays the number of days corresponding to the month number entered by the user. For example, when the user enters the number 7, the program should display the number 31. However, if the user enters the number 2, the program should ask the user for the year. The rules for determining whether a year is a leap year are shown in Figure 11-51. If the year is a leap year, the program will need to add 1 to the number of days before displaying the number of days on the screen. The program should also display an appropriate message when the user enters an invalid month number. Use a sentinel value to end the program. Save and then run the program. Test the program using the number 1, and then test it using the numbers 3 through 12. Test it using the number 2 and the year 2015. Then, test it using the number 2 and the year 2016. Also test it using an invalid number, such as 20.
Step by Step Answer:
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell