fork download
  1. import java.io.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) throws IOException {
  5. System.out.print("テストの点数を入力してください ");
  6. int grade = getGrade(Integer.parseInt(br.readLine()));
  7.  
  8. if(grade == 4) {
  9. System.out.print("秀");
  10. } else if(grade == 3) {
  11. System.out.print("優");
  12. } else if(grade == 2) {
  13. System.out.print("良");
  14. } else if(grade == 1) {
  15. System.out.print("可");
  16. } else {
  17. System.out.print("不可");
  18. }
  19. }
  20.  
  21. public static int getGrade(int score) {
  22. if(score >= 90) {
  23. return 4;
  24. } else if(score >= 80) {//else if(score >= 80 && score < 90)
  25. return 3;
  26. } else if(score >= 70) {
  27. return 2;
  28. } else if(score >= 60) {
  29. return 1;
  30. } else {
  31. return 0;
  32. }
  33. }
  34. }
  35.  
Runtime error #stdin #stdout #stderr 0.06s 32976KB
stdin
Standard input is empty
stdout
テストの点数を入力してください 
stderr
Exception in thread "main" java.lang.NumberFormatException: null
	at java.base/java.lang.Integer.parseInt(Integer.java:620)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:7)