Question: Exercise 2-Implementing a class and tester (3 points) The exercise must be completed during the lab period. Develop a program that transforms the numbers 1,

 Exercise 2-Implementing a class and tester (3 points) The exercise must

Exercise 2-Implementing a class and tester (3 points) The exercise must be completed during the lab period. Develop a program that transforms the numbers 1, 2, 3, 4, ..., 12 into the corresponding month names: January, February, March,December. Implement the class Month whose constructor parameter is a month number (1...12). Create a method getName () that returns the month name (a String) The solution must use a long string that contains all of the month names: January February MarchApril .etc Take care to add spaces between the month names so that each month name, along with added spaces is the same length (9 characters. longest month name September). Use the substring () method of the String class to extract the correct month (see the Java API for details) Create a class MonthTester that uses Scanner to get the month number, create a Month object and produce an output as shown below: Enter the month number (1 - 12): 4 The month is: April or: Enter the month number (1 - 12): 9 The month is: September What happens if you enter a 0 or a 13 for the month number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!