HR자바 Java Int to String

개요[ | ]

HR자바 Java Int to String
해커랭크 Java
# 문제 비고
HR자바 Introduction e
1 HR자바 Welcome to Java!
2 HR자바 Java Stdin and Stdout I
3 HR자바 Java If-Else
4 HR자바 Java Stdin and Stdout II
5 HR자바 Java Output Formatting
6 HR자바 Java Loops I
7 HR자바 Java Loops II
8 HR자바 Java Datatypes
9 HR자바 Java End-of-file
10 HR자바 Java Static Initializer Block
11 HR자바 Java Int to String
12 HR자바 Java Date and Time
13 HR자바 Java Currency Formatter

Java
Copy
import java.util.*;
import java.security.*;
public class Solution {
    public static void main(String[] args) {
        DoNotTerminate.forbidExit();
        try {
            Scanner in = new Scanner(System.in);
            int n = in .nextInt();
            in.close();
            //String s=???; Complete this line below
Java
Copy
            //Write your code here
            String s = String.valueOf(n);
Java
Copy
            if (n == Integer.parseInt(s)) {
                System.out.println("Good job");
            } else {
                System.out.println("Wrong answer.");
            }
        } catch (DoNotTerminate.ExitTrappedException e) {
            System.out.println("Unsuccessful Termination!!");
        }
    }
}

//The following class will prevent you from terminating the code using exit(0)!
class DoNotTerminate {
    public static class ExitTrappedException extends SecurityException {
        private static final long serialVersionUID = 1;
    }
    public static void forbidExit() {
        final SecurityManager securityManager = new SecurityManager() {
            @Override
            public void checkPermission(Permission permission) {
                if (permission.getName().contains("exitVM")) {
                    throw new ExitTrappedException();
                }
            }
        };
        System.setSecurityManager(securityManager);
    }
}