for this program
import javax.swing.JOptionPane;
public class TEMPO
{
public static void main (String args[])
{
int temp;
String tempString;
String contString;
char charAns;
do
{
tempString = JOptionPane.showInputDialog(null, "Enter the temperature:",
"Input",JOptionPane.QUESTION_MESSAGE);
temp = Integer.parseInt(tempString);
if (temp < 10 )
JOptionPane.showMessageDialog(null,"Too Cold", "Output",
JOptionPane.INFORMATION_MESSAGE);
else if (temp >= 10 && temp <= 20)
JOptionPane.showMessageDialog(null,"Average", "Output",
JOptionPane.INFORMATION_MESSAGE);
else if (temp >= 21 && temp <= 30)
JOptionPane.showMessageDialog(null, "Hot", "Output",
JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null, "Too Hot", "Output",
JOptionPane.INFORMATION_MESSAGE);
contString =
JOptionPane.showInputDialog(null, "Would you like to continue (y/n):",
"Input",JOptionPane.QUESTION_MESSAGE);
charAns = contString.charAt(0);
}while (charAns !='n');
System.exit(0);
}
}
the problem is, when i enter other that 'y', the program accepts it.how to make it only accept 'y' as the answer.
pls help...
tq & rgds