本人遇到一个问题:
代码如下:
public class TestJs 
{
public static void main(String[] args) 
{
  score(95);// System.out.println("优秀!");}
public static void score(int x) 
{  
  if (x > 100 || x < 0)
System.out.println("输入错误!!");
else if 
(x >= 90)System.out.println("优秀!");
else if (x >= 80)
System.out.println("良好!");
else
System.out.println("及格!");
}
}
运行时出现问题如下:
D:\java\zuoye2>javac TestJs.java
TestJs.java:41: 非法的表达式开始
                             public static  void getGrade(int x) {
                             ^
TestJs.java:41: 非法的表达式开始
                             public static  void getGrade(int x) {
                                    ^
TestJs.java:41: 需要 ';'
                             public static  void getGrade(int x) {
                                          ^
TestJs.java:41: 需要 ".class"
                             public static  void getGrade(int x) {
                                                              ^
TestJs.java:41: 需要 ';'
                             public static  void getGrade(int x) {
                                                               ^
5 错误
跪求各位前辈解答,谢谢 大家!!

解决方案 »

  1.   

    public static void main(String[] args)  
    {
      score(95);// System.out.println("优秀!");}
    public static void score(int x)  后面漏了一个  }
      

  2.   

    public class TestJs  
    {
    public static void main(String[] args)  
    {
      score(95);// System.out.println("优秀!");
    }
    public static void score(int x)  
    {   
      if (x > 100 || x < 0)
    System.out.println("输入错误!!");
    else if  
    (x >= 90)System.out.println("优秀!");
    else if (x >= 80)
    System.out.println("良好!");
    else
    System.out.println("及格!");
    }
    }
      

  3.   

    public class TestJs  
    {
    public static void main(String[] args)  
    {
      score(95);// System.out.println("优秀!");}
    }//main 方法结束,你漏了这个}
    public static void score(int x)  
    {   
      if (x > 100 || x < 0)
    System.out.println("输入错误!!");
    else if  
    (x >= 90)System.out.println("优秀!");
    else if (x >= 80)
    System.out.println("良好!");
    else
    System.out.println("及格!");
    }
    }
      

  4.   

     score(95);// System.out.println("优秀!");} 改为  score(95);// System.out.println("优秀!");
    }   两行
      

  5.   

    温馨提示:
    1、像这种牵一发动全身报数量惊人错误的,通常是少了个符号(一般是右大括号)2、建议楼主把代码弄得好看点,
    我这里假装楼主还不会使用插入代码的功能:点击菜单栏里面的插入源代码,选择java,然后把代码放进去,主意是在两个中括号之间(靠,我真是太有耐心了)