pls help me to solve my problem.
here's my code
import java.io.*;
public class ifelse {
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int a;
System.out.println("Enter your Level");
a = Integer.parseInt(in.readLine());
if (a == 1)
System.out.println("\nYou are Freshman");
else if (a == 2)
System.out.println("\nYou are Sophomore");
else if (a == 3)
System.out.println("\nYou are Junior");
else if (a == 4)
System.out.println("\nYou are Senior");
else if (a == a)
System.out.println("\nYou are Senior");
else
System.out.println("\nInvalid input\nEnter Valid Year Level");
}
}
how to prevent this error
Exception in thread "main" java.lang.NumberFormatException: For input string: "a"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at ifelse.main(ifelse.java:19)
this code will come out when i enter any letter
thanks for the answer god bless