Java: java.lang.NumberFormatException
do{
System.out.println("Input:\n(Consider the input is from the
sensor)\n");
temperature = Integer.parseInt(br.readLine());
examineTemperature(temperature);
System.out.println("Does the sensor wanna continue giving
input?:(y/n)\n");
c = (char) br.read();
}while(c!= 'N' || c!='n');
I don't understand where i went wrong because I am getting an error as
shown below in eclipse:
Input:
(Consider the input is from the sensor)
45
Temperature is 45 in celcius. Hmmm...
Thats 113 in Farenheit...
***The weather is niether too hot nor too cold***
Does the sensor wanna continue giving input?:(y/n)
N
Input:
(Consider the input is from the sensor)
Exception in thread "main" java.lang.NumberFormatException: For input
string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at tempdetection.main(tempdetection.java:33)
I got my answer and then its throwing this exception... If i press
Anything other than N it loops but again throws this exception.. Why so??
No comments:
Post a Comment