컴파일 실패 오류가 계속 납니다.

  • JinsungLee
    JinsungLee

    import java.util.Scanner;

    public class Encryption {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    
        int repeat;
        while(true) {
            repeat = sc.nextInt();
            if(repeat < 1 || repeat > 10)
                System.out.println("input length between 1 to 10");
            else
                break;
        }
    
        Str[] str = new Str[repeat];
    
        for(int i=0; i<repeat; i++) {
            String s;
            while(true) {
                s = sc.next();
                if(s.length() > 100)
                    System.out.println("input length between 1 to 100");
                else
                    break;
            }
    
            str[i] = new Str();
    
            char[] c = new char[s.length()];
            for(int j=0; j<s.length(); j++) {
                c[j] = s.charAt(j);
                if(j % 2 == 0)
                    str[i].even += c[j];
                else
                    str[i].odd += c[j];
            }
        }
    
        try {
            sc.close();
        }catch(Exception e) { }
    
        for(int i=0; i<str.length; i++) {
            System.out.println(str[i].even + str[i].odd);
        }
    }

    }

    class Str {
    String odd = "";
    String even = "";
    }

    문자열_암호화 문제입니다.
    소스코드입니다.
    결과로는 컴파일 실패라고 나옵니다.
    에러 메시지로는 다음과 같이 나옵니다.

    MONITOR:
    RTE (nonzero return code)

    STDERR:
    Main.java:4: error: class Encryption is public, should be declared in a file named
    Encryption.java
    public class Encryption {

    1 error

    STDOUT:

    ※ 알고스팟 이용하고 첫 답을 올리는 것인데 양해부탁드립니다.


    9년 전
1개의 댓글이 있습니다.
  • VOCList
    VOCList

    클래스명을 Main으로 시도해보시기 바랍니다.


    9년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.