Question: 3. Writing a Class that Uses the Switch Statement In this practice, you create a class called Month that uses switch statements to display the

 3. Writing a Class that Uses the Switch Statement In this

3. Writing a Class that Uses the Switch Statement In this practice, you create a class called Month that uses switch statements to display the name of the month based upon the numeric value of a field. i. Create a new Java class called "Month. ii. Declare an int field in the Month class called monthNumber. Assign a value to the field that is between 1 and 12 (inclusive), where 1 represents the month of January and 12 represents the month of December. iii. Create a new method in the Month class called displayMonth. This method uses a switch construct to inspect the value of the month Number field and display the corresponding name of the month. The displayMonth method should also display an error message if an invalid number is used. iv. Save, compile, and execute your program by running the Month Test class(This is the controlling class that you should create). V Repeat step 4 several times assigning different values to the monthName field

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!