본문 바로가기
코딩테스트/자바 Level 0

[Java] 덧셈식 출력하기

by onggury 2023. 7. 31.

문제

두 정수 ab가 주어질 때 다음과 같은 형태의 계산식을 출력하는 코드를 작성해 보세요.

  • a + b = c

 

제한사항

  • 1 ≤ a, b ≤ 100

 

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.printf("%d + %d = %d", a, b, a + b);
    }
}

 

 

출처

https://school.programmers.co.kr/learn/courses/30/lessons/181947