자바

[JAVA] 변수와 자료형

코딩하는둥이 2022. 11. 19. 18:18

1. 정수 선언하고 뺄셈

 

public class Main {
    public static void main(String[] args) {
        int A = 97;
        int B = 13;
        System.out.println(A + " - " + B +" = "+ (A-B));
        // Your Program Goes Here
    }
}

정답:  97 - 13 = 84

 

 

2. 변수 선언하기

public class Main {
    public static void main(String[] args) {
        int a = 3;
        String b = "C";

        System.out.println(a);
        System.out.println(b);
        // Your Program Goes Here
    }
}

정답

3

C

 

3. 정수 선언하고 곱 출력

public class Main {
    public static void main(String[] args) {
        int A = 26;
        int B = 5;
        System.out.println(A + " * " + B +" = "+ (A*B));
        // Your Program Goes Here   // Your Program Goes Here
    }
}

 

정답: 26 * 5 = 130