Question: Write a class named MonthDays . The class should have fields to hold the number of the month (i.e. January is month 1) and the
Write a class named MonthDays. The class should have fields to hold the number of the month (i.e. January is month 1) and the year. Create a minimum to two constructors. Be sure to include accessors and mutators (getters and setters) for each field. Create a method named getNumberofDays that returns the number of days in the specified month. You can determine a leap year based on the following criteria:
(1) If the year is divisible by 100 it is a leap year only if it is also divisible by 400. For example 2000 is a leap year but 2100 is not. (2) If the year is not divisible by 100 it is a leap year if it is divisible by 4.
Create an application to test the class. Create a minimum of two MonthDays objects. Allow the user to enter the month and the year. Be sure to validate the user data for months being 1 - 12 only. The program should then display the number of days for each month.
You may read and write from the console window. Make sure your input and output are formatted nicely and easy to read.
You are to submit your MonthDays.java and the test application .java file in Moodle by the due date.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
