For the following problem, work through steps 1 (Understanding) through 5 (Desk Checking) of the Steps in Program Development discussed in lectures.
Write a program to display the number of days in a month. The user is to input the month number. Validate the month number using an appropriate loop before determining the number of days in the month. Assume there are 28 days in February.
Example Runs
Run Month Number (1 to 12, 0 to exit) ? 5 31 days Month Number (1 to 12, 0 to exit) ? 2 28 days Month Number (1 to 12, 0 to exit) ? 11 30 days Month Number (1 to 12, 0 to exit) ? 13 Error: month number must be between 1 and 12, or 0 to Exit Month Number (1 to 12, 0 to exit) ? 0
What would the condition be for validating the month if -1 was used to exit the loop instead of 0? Desk check your condition with appropriate values.
The above problem is a simplification of the real problem. What other information needs to be input by the user to be able to determine the correct number of days in a month? Under what circumstances is it needed?
Catch up on any problems from previous tutorials that you haven't completed. Take this opportunity to discuss any queries or problems from previous tutorials with your tutor.