Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9. Days in a Month we a class named Mathays. The class constructor should pro met An integer for the month January, 2 February.ee An

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

9. Days in a Month we a class named Mathays. The class constructor should pro met An integer for the month January, 2 February.ee An integer for the year The class should have a method named get beror Days that returns the mumber of days in the specified month. The method should use the following criteria to identify leap years 1. Determine whether the year is divisible by 100. If it is, then it is a leap year it and if only it is divisible by 400. For example, 2000 is a leap year but 2100 is not 2. If the year is not divisible by 100, then it is a leap year it and it only it is divisible by 4. For example, 2008 is a leap year but 2009 is not Demonstrate the class in a program that asks the user to enter the month letting the user enter an integer in the range of 1 through 12) and the year. The program should then dis play the number of days in that month. Here is a sample run of the program Enter a month (1-12)1 2 [Enter] Enter a year 2008 [Enter] 29 days Complete Programming Challenge 9, Days in a Month (on page 399 in the text book). Non-OOP solution receives 0. Before you start your design and coding for the program, please read the description in the book and my notes below: In the service class, MonthDays, in addition to the constructor (with two parameters) and other methods specified in the textbook, you need to have other methods. Together the class should include: 1) A default constructor 2) A constructor with parameters for month and year 3) Mutators for all data members 4) Accessors for all data members 5) The method, getNumberOfDays, which returns the number of days Note: In a leap year and non-leap years, February has different days! 6) The method, getMonthName() to convert a month number into an actual month name, such as "February", "March", and so on, and returns the month name. 7) The output() method which display results, such as February in year 2008 has 29 days." As a programmer, your tasks are to design the program in a class diagram, and then implement the design in Java program. Create a class diagram which includes both service and application classes with relationship: 0 You can simply use a table to create the diagram on the Word document directly. Or use any other tool to draw the diagram, and then paste it as image into the Word document. Implement the design in Java code O In the service class or in the application class, validate year and month. If in the service class, need to validate the parameters in methods which are used to initialize or set/mutate year and month. If in the application class, validate the inputs before passing them as arguments to the methods. If any of them it is invalid, terminate the program. In Gregorian Calendar, if a year value is less than 1582, it is invalid. The month value should be in 1 to 12 Create an application class (a separate class) to test the service class. You can use the following cases to test your program: o Enter a month (1-12): 14 Invalid month! Enter a month (1-12): 2 Enter a year: 1580 Invalid year! Enter a month (1-12): 2 Enter a year: 1900 February in 1900 has 28 days Enter a month (1-12): 2 Enter a year: 2008 February in 2008 has 29 days Enter a month (1-12): 4 Enter a year: 2011 April in 2011 has 30 days Enter a month (1-12): 10 Enter a year: 2015 October in 2015 has 31 days

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

Genetic Databases

Authors: Martin J. Bishop

1st Edition

0121016250, 978-0121016258

More Books

Students also viewed these Databases questions