Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions