Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

must be in java: In this problem you ask the user for a month and day. You will then calculate the season based on the

must be in java:

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

Create a class named Problem2

Create two integer instance variables, month and day.

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

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

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

Return Season

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

Import Scanner

Create a Scanner object

Prompt the use to enter a month as a number

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

Prompt the use to enter a day as a number

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

Create a Problem2 object

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

More Books

Students also viewed these Databases questions