Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. a. Write a class named Month. The data members of the class should have an int field named month Number that holds the month

image text in transcribed
7. a. Write a class named Month. The data members of the class should have an int field named month Number that holds the month number. For example, January would be 1, February would be 2. and so forth. It has an String array containing all 12 month names: month[0] = "January, month(1) = "February", etc. public class Month private int monthNum; private String[months = {"January", "February", "March", "April", "May", "June". "July". "August", "September", "October", "November", "December"}; 7. b. Write a no-argument constructor that sets the monthNumber field to 1. public Month monthNum = 1; 7. c. Write a constructor that accepts the month number as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than 1 or greater than 12 is passed, the constructor should set monthNumber to 1. public Month(int monthNum) 12) if(this.monthNum >= 1 && this.monthNum this monthNum = monthNum; else monthNum = 1; 7. d. Write 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. public Month(String monthName) for(int i = 2; i

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Compare a delusion with a hallucination.

Answered: 1 week ago