[백준] 10869 사칙연산

차누·2024년 2월 27일
0

문제

두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.

출력

첫째 줄에 A+B, 둘째 줄에 A-B, 셋째 줄에 A*B, 넷째 줄에 A/B, 다섯째 줄에 A%B를 출력한다.

풀이방법

각 케이스마다 합, 빼기, 곱하기, 몫, 나머지를 출력해주면 된다
(출력할 때 println()으로 해줘야 한다)

import java.util.Scanner;

public class bj_10869 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		System.out.println(A + B);
		System.out.println(A - B);
		System.out.println(A * B);
		System.out.println(A / B);
		System.out.println(A % B);
	}

}
profile
to be good programmer

0개의 댓글

Powered by GraphCDN, the GraphQL CDN