Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An Introduction to Programming with C++ by Diane Zak Exercise 26: If necessary, create a new project named Advanced26 Project and save it in the

An Introduction to Programming with C++ by Diane Zak

Exercise 26:

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 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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago