Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write A class named Month. The class should have an int field named monthNumber that holds the number of the month. For example, January would

Write A class named Month. The class should have an int field named monthNumber that holds the number of the month. For example, January would be 1, February would be 2, and so forth. In addition, provide the following methods: A no-arg constructor that sets the monthNumber field to I. A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than I or greater than 12 is passed, the constructor should set monthNumber to I. A constructor that accepts the name of the month, such as "January" or "February" as an argument. It should set the monthNumber field to the correct corresponding value, A setMonthNumber method that accepts an i n t argument, which is assigned to the monthNumber field. If a value less than 1 or greater than 12 is passed, the method should set monthNumber to 1. A getMonthNumber method that returns the value in the monthNumber field. A getMonthName method that returns the name of the month. For example, if the monthNumber field contains 1, then this method should return "January". A toString method that returns the same value as the getMonthName method. An equals method that accepts a Month object as an argument. If the argument object holds the same data as the calling object, this method should return true. Otherwise, it should return false. A greaterThan method that accepts a Month object as an argument. If the calling objects monthNumber field is greater than the argument's monthNumber fields this method should return true. Otherwise, it should return false. A less Than method that accepts a Month object as an argument. If the calling object's monthNumber field is less than the arguments monthNumber field, this method should return true. Otherwise, it should return false

Once you write the class, you could prompt a user to enter a number of a month, or a month name so that output provides a month name when a number is entered or the number of the month is displayed when a month name is entered.

For example in pseudocode: Enter either a number of a month or a month name

Return for this would be what I described above. Consider providing a couple of run code examples to illustrate that when a user is prompted and enters the number 5 that the month May is returned. When the month November is entered by a user, the number 11 is displayed.

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

Identify five strategies to prevent workplace bullying.

Answered: 1 week ago