I am to have the user input a temperature and have the computer output which season it (probably) is based on the temperature entered. I have written this much and when I run the program, it seems to have the user enter the temperature in an input box and then won't return the probable season until the user enters it in the bottom of the program. I'm using JGrasp. I've been trying diffferent things but can't seem to come up with a solution. Any ideas?
Also, I'm having problems with the loop too.
import java.util.Scanner;
import javax.swing.JOptionPane;
public class TEMPERATUREHW1016
public static void main(String [] args)
{
int temp;
String runAgain;
Scanner input = new Scanner(System.in);
//do
{
JOptionPane.showInputDialog(null,"Enter Temperature: ");
temp = input.nextInt();
findSeason(temp);
runAgain = input.next();
}
while((runAgain.equalsIgnoreCase("y")));
}
public static void findSeason(int temp)
{
if (temp > 110 || temp < -5)
JOptionPane.showMessageDialog(null,"The temperature entered is outside the valid range.");
else if (temp >= 90)
JOptionPane.showMessageDialog(null,"It is probably summer.");
else if (temp >= 70 && temp < 90)
JOptionPane.showMessageDialog(null,"It is probably spring.");
else if (temp >= 50 && temp < 70)
JOptionPane.showMessageDialog(null,"It is probably fall.");
else if (temp < 50)
JOptionPane.showMessageDialog(null,"It is probably winter.");
}
}