AVA: My code encounters the following problem. Could you fix it? The purpose of this code is to input the date and output the season. import java.util.Scanner; public class Seasons { public static String getMonth(Scanner console){ System.out.print("Enter the month: "); String month = console.nextLine().trim(); return month; } public static int getDay(Scanner console){ System.out.println("Enter day: "); int day = console.nextInt(); return day;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

JAVA: My code encounters the following problem. Could you fix it? The purpose of this code is to input the date and output the season.

import java.util.Scanner;

public class Seasons {
public static String getMonth(Scanner console){
System.out.print("Enter the month: ");
String month = console.nextLine().trim();
return month;
}

public static int getDay(Scanner console){
System.out.println("Enter day: ");
int day = console.nextInt();
return day;
}

public static boolean ValidInput(String InputMonth, int InputDay){
String[] monthName = {"January","Feburary","March","April","May","June","July","August",
"September","October","November","December"};
int[] day = {31,28,31,30,31,30,31,31,30,31,30,31};

if(InputDay<0){
return false;
}

for(int i=0 ; i<12; i++){
if(InputMonth.equalsIgnoreCase(monthName[i])){
if(InputDay <= day[i])
return true;
else
return false;
}
}
return false;
}

public static String calcSeason(String InputMonth, int InputDay){
String season = "";
if(InputMonth.equalsIgnoreCase("December")){
if(InputDay >= 21)
season = "winter";
else
season = "Fall";
}

if(InputMonth.equalsIgnoreCase("January") || InputMonth.equalsIgnoreCase("Feburary"))
season = "winter";

if(InputMonth.equalsIgnoreCase("March")) {
if(InputDay <= 19)
season = "winter";
else
season = "spring";
}

if(InputMonth.equalsIgnoreCase("April") || InputMonth.equalsIgnoreCase("May"))
season = "spring";
if(InputMonth.equalsIgnoreCase("June")) {
if(InputDay <= 20)
season = "spring";
else
season = "summer";
}

if(InputMonth.equalsIgnoreCase("July") || InputMonth.equalsIgnoreCase("August"))
season = "summer";

if(InputMonth.equalsIgnoreCase("September")){
if(InputDay <= 20)
season = "summer";
else
season = "fall";
}

if(InputMonth.equalsIgnoreCase("October") || InputMonth.equalsIgnoreCase("November"))
season = "fall";

return season;
}

public static void displaySeason(String season){
System.out.println("This date occurs in the "+season+".");
}

public static void main(String[] args) {
//create object of Scanner class to get input from user
Scanner console = new Scanner(System.in);

//variable declaration
String month;
int day;

//function calling and set month and date variables
month = getMonth(console);
day = getDay(console);
if(ValidInput(month,day)){
String season = calcSeason(month,day);
displaySeason(season);
}
else
System.out.println("Invalid date. Program cannot continue.");
}

}

 

Test the method call: validinput("2PRIL", 11)
| Compilation failed
zyLabsUnitTest.java:7: error: cannot find symbol
boolean studentResult = studentClass.validInput ("APRIL", 11);
Compilation failed
symbol:
method validInput (String,int)
location: variable studentClass of type Seasons
1 error
Transcribed Image Text:Test the method call: validinput("2PRIL", 11) | Compilation failed zyLabsUnitTest.java:7: error: cannot find symbol boolean studentResult = studentClass.validInput ("APRIL", 11); Compilation failed symbol: method validInput (String,int) location: variable studentClass of type Seasons 1 error
Check existence of required methods.
This unit test checks that the required methods
have been implemented.
Method "getMonth": Found OK
Method "getDay": Found OK
Test feedback
Method "validInput": Not Found
Method "calcSeason": Found OK
Method "displaySeason": Found OK
At least one required method not found.
Transcribed Image Text:Check existence of required methods. This unit test checks that the required methods have been implemented. Method "getMonth": Found OK Method "getDay": Found OK Test feedback Method "validInput": Not Found Method "calcSeason": Found OK Method "displaySeason": Found OK At least one required method not found.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education