本人是一个初出学者,现在遇到一个问题:
代码如下:
public class TestJs {
public static void main(String[] args) {
String str = score(95);
System.out.println("优秀!");
}
public static String 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("良好"!);
esle
System.out.println("及格!");
}
}
本人不知道那个地方出错,跪求各位大侠指点,在此先谢过啦!!
本人很急啊
代码如下:
public class TestJs {
public static void main(String[] args) {
String str = score(95);
System.out.println("优秀!");
}
public static String 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("良好"!);
esle
System.out.println("及格!");
}
}
本人不知道那个地方出错,跪求各位大侠指点,在此先谢过啦!!
本人很急啊
public static void main(String[] args) {
String str = score(95);
System.out.println("优秀!");
} public static String 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("及格!");
return null;
}
}score方法的 返回值忘记了
这个是干啥的
我猜你的意思是 System.out.println(str);吧
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("及格!"); }
}
public class TestJs {
public static void main(String[] args) {
String str = score(95);
System.out.println(str);
} public static String score(int x) {
String str = "";
if (x > 100 || x < 0) {
str = "输入错误!!";
System.out.println("输入错误!!");
} else if (x >= 90) {
str = "优秀!";
System.out.println("优秀!");
} else if (x >= 80) {
str = "良好!";
System.out.println("良好!");
} else {
str = "及格!";
System.out.println("及格!");
}
return str;
}
}
public static void main(String[] args) {
String str = score(95);
System.out.println(str);
} public static String score(int x) {
if (x > 100 || x < 0)
return "输入错误!!"; else if (x >= 90)
return "优秀!";
else if (x >= 80)
return "良好!";
else
return "及格!"; }
}