Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java only: In this problem you ask the user for a month and day. You will then calculate the season based on the month and

Java only: In this problem you ask the user for a month and day. You will then calculate the season based on the month and day.

Part 1:

a. Create a class named Problem2

b. Create two integer instance variables, month and day.

c. Create a constructor to initialize the variable. The constructor should have 2 arguments, m and d. Initialize month and day with these two arguments.

d. Create a method called calcSeason. It should not have any arguments and should return a string.

e. The method should implement the following algorithm:

If month is 1,2, or 3, season = Winter

Else if month is 4,5, or 6, season = Spring

Else if month is 7,8, or 9, season = Summer

Else season = Fall

If month is divisible by 3 and day >=21

If season is Winter, season = Spring

Else if season is Spring, season = Summer

Else if season is Summer season = Fall

Else season = Winter

f. Return Season

Part 2:

a. Create a class named Problem2Tester (reminder: all tester classes have a main method)

b. Import Scanner

c. Create a Scanner object

d. Prompt the use to enter a month as a number

e. Get the number from the user and store it as a variable

f. Prompt the use to enter a day as a number

g. Get the number from the user and store it as a variable

h. Create a Problem2 object

i. Print the result from calcSeason (this can be done directly in the print statement or you can create a new variable and print it)

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions