Write a program that reads a temperature as a whole number f
Write a program that reads a temperature as a whole number from the keyboard and outputs a probable season (winter, spring, summer, or fall) depending on the temperature. If the temperature is greater than or equal to 90, it is probably summer. If the temperature is greater than or equal to 70 and less than 90, it is probably spring. If the temperature is greater than or equal to 50 and less than 70, it is probably fall. If the temperature is less than 50, it is probably winter. If the temperature is greater than 110 or less than -5, then you should output that the temperature entered is outside the valid range.
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
class Temperature
{
public static void main(String args[])
{
int temp;
String runAgain;
Scanner input = new Scanner(System.in);
do
{
System.out.print(\"Enter Temperature: \");
temp = input.nextInt();
findSeason(temp);
System.out.print(“Enter y or yes to run the program again: ”);
runAgain = input.next();
}
while(runAgain.toUpperCase == \'\'Y\" || runAgain.toUpperCase == \"YES\");
}
public static void findSeason(int temp)
{
if(temp > 110 || temp < -15)
System.out.println(“The temperature entered is outside the valid range.”);
else if(temp >= 90)
System.out.println(“It is probably summer.”);
else if(temp >= 70 && temp < 90)
System.out.println(“It is probably spring.”);
else if(temp >= 50 && temp < 70)
System.out.println(“It is probably fall.”);
else if(temp < 50)
System.out.println(“It is probably winter.”);
}
}

