我的作业说明在
之下使用System.out.println()方法告诉学生如果他们输入的分数不是一个字母以外的任何内容,请再试一次。
这是我正在使用的代码
import java.io.IOException;
import java.util.Scanner;
public class MyGradeLoops {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
for (int x = 1; x <= 5; x++) {
System.out.println("Please enter Your Class Grades");
String A;
char B;
A = in.next();
System.out.println("Thank You");
if (**TRYING TO TEST FOR MORE THAN ONE LETTER**) {
System.out.println("Only One Letter At A Time");
}
}
System.out.println("Keep Up The Good Work")
}
}
感谢任何帮助
答案 0 :(得分:1)
import java.io.IOException;
import java.util.Scanner;
public class MyGradeLoops {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
for (int x = 1; x <= 5; x++) {
System.out.println("Please enter Your Class Grades");
String A;
char B;
A = in.next();
System.out.println("Thank You");
if (A.length() != 1) {
System.out.println("Only One Letter At A Time");
}
}
System.out.println("Keep Up The Good Work");
}
}