Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
我不断收到此错误代码:

---- jGRASP执行:javac -g RomanNumerals.java

RomanNumerals.java:56:无法访问的语句

充实:

1个错误

---- jGRASP楔形:进程的退出代码为1。
 ---- jGRASP:操作完成。

到目前为止,这是我的代码:

import java.util.Scanner;

public class RomanNumerals
{
   public static void main(String[] args)
   {
      int input;

      Scanner keyboard = new Scanner(System.in);

      System.out.print("Enter a number: ");
      input = keyboard.nextInt();

      switch (input)
      {
         case 1:
            System.out.println("I");
            break;
         case 2:
            System.out.println("II");
            break;
         case 3:
            System.out.println("III");
            break;
         case 4:
            System.out.println("IV");
            break;
         case 5:
            System.out.println("V");
            break;
         case 6:
            System.out.println("VI");
            break;
         case 7:
            System.out.println("VII");
            break;
         case 8:
            System.out.println("VIII");
            break;
         case 9:
            System.out.println("IX");
            break;
         case 10:
            System.out.println("X");
            break;
         defult:
            System.out.println("Please enter a number between 1 and 10. ");
     }
   }
}

最佳答案

您输入了“默认值:”,但应为“默认值:”
尝试

default:
            System.out.println("Please enter a number between 1 and 10. ");

08-17 11:25