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.");

   }
}
JOptionPane.showInputDialog(null,"Enter Temperature: ");
temp = input.nextInt();

You display the input dialog, but you do nothing with the result that it returns you.
You then go back to the console to read an int.
So the user enters something in the dialog, you ignore that, then he has to enter it again on the console.
Check the API doc for JOptionPane.showInputDialog - see what it returns.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.