use this code, you got error bcoz:-
1. you have to initialize the the variable
...
![Quote](https://www.javaprogrammingforums.com/images/misc/quote_icon.png)
Originally Posted by
RevChe
Hello everyone,
Its my first time posting here and im very thankful for the work you guys do here
Heres a java assignment i just received from my class and i think i did some of it right.
Can someone please tell me why this wont compile properly.
import java.io.*;
class Question07{
public static void main(String args[]) throws IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter GPA : ");
double gpa = Double.parseDouble(stdin.readLine());
if(gpa>=3.5){
int a = 1;
}else if(gpa>=3.49 & gpa >= 3.00){
int a = 2;
}else if(gpa>=2.99 & gpa>=2.5){
int a = 3;
}else if(gpa>=2.49 & gpa>=2.00){
int a = 4;
}else if(gpa<2.0){
int a = 5;
}else{
break;
}
int x = a;
switch(x){
case (1):
System.out.println("First Class\n");
break;
case(2):
System.out.println("Upper second class\n");
break;
case(3):
System.out.println("Lower secodn class\n");
break;
case(4):
System.out.println("Pass\n");
break;
case(5):
System.out.println("Fail\n");
break;
default:
System.out.println("Invalid GPA\n");
}
}
}
Its good if someone can tell me what iv done wrong and how to correct it with good visual example.I just dont seem to have a good time with java
Thanks in advance