Identifier expected

+2 Arnab Banerjee · January 24, 2015
import java.util.*;
static int grade;
public class{
public static void main(String args[]){
System.out.println(" Enter your grade ");
Scanner input = new Scanner(System.in);
grade = input.nextInt();

switch(grade){
case 9:
System.out.println("Out standing");
break;
case 8:
System.out.println("Excellent");
break;
case 7:
System.out.println("Very good");
break;
case 6:
System.out.println("Good");
break;
case 5:
System.out.println("Satisfactory");
break;
default:
System.out.println("Failed");

}
}
}

What's wrong in this code ? :P 

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
+1 Mr. Computer · January 24, 2015
import java.util.*;

public class apples{
public static void main(String args[]){
int grade;
System.out.println(" Enter your grade ");
Scanner input = new Scanner(System.in);
grade = input.nextInt();

switch(grade){
case 9:
System.out.println("Out standing");
break;
case 8:
System.out.println("Excellent");
break;
case 7:
System.out.println("Very good");
break;
case 6:
System.out.println("Good");
break;
case 5:
System.out.println("Satisfactory");
break;
default:
System.out.println("Failed");

}
}
}






Worked for me :D i got 10 but failed ! Aahah
+1 Arnab Banerjee · January 24, 2015
:P :P 
+1 Arnab Banerjee · January 24, 2015
import java.util.*;
public class prog3{
public static void main(String args[]){
int grade;
System.out.println(" Enter your grade ");
Scanner input = new Scanner(System.in);
grade = input.nextInt();

switch(grade){
case 10:
System.out.println("You got Full grade");
break;
case 9:
System.out.println("Out standing");
break;
case 8:
System.out.println("Excellent");
break;
case 7:
System.out.println("Very good");
break;
case 6:
System.out.println("Good");
break;
case 5:
System.out.println("Satisfactory");
break;
default:
System.out.println("Failed");

}
}
}

Still not working, feeling confused.  :'( .
+1 Mr. Computer · January 24, 2015
Error: Could not find or load main class apples


is this the error u get ?
0 Arnab Banerjee · January 24, 2015
no. it's saying identifier expected. 
0 Mr. Computer · January 24, 2015
import java.util.*;
public class prog3{
public static void main(String args[])



i think the porblem is with the 

public class prog3


u have to change it with the correct name of ur main class 
0 Arnab Banerjee · January 24, 2015
Ok I am doing it. 
+1 Mr. Computer · January 24, 2015
i hope i helped :) 

let me know when its working 
+1 Neil Cannon · January 24, 2015
import java.util.*;

public class Prog3{
       
    public static void main(String args[]){
        System.out.println(" Enter your grade ");
        Scanner input = new Scanner(System.in);

        int grade = 0;
        for (int i = 1; i <= 9; i++) {
        grade = input.nextInt();
        
        switch(grade){
            case 0:
            System.out.println("Embarrassing!?");
            break;
            case 1:
            System.out.println("Fail!");
            break;
            case 2:
            System.out.println("Fail!");
            break;
            case 3:
            System.out.println("Fail!");
            break;
            case 4:    
            System.out.println("Fail!");
            break;
            case 5:
            System.out.println("Satisfactory");
            break;
            case 6:
            System.out.println("Good");
            break;
            case 7:
            System.out.println("Very Good");
            break;
            case 8:
            System.out.println("Excellent");
            break;
            case 9:
            System.out.println("Out Standing");
            break;
            default:
            System.out.println("Genius");    
            
            input.close();
        
           }
            
        }
    }
}
            
        
    


//// try this code, you may want to modify ////
+1 Arnab Banerjee · January 24, 2015
Thanks Mozamel and Neil, it's working now. :) 
  • 1
  • 2

Java / Android Development

106,961 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator