포스트

[Java] Baekjun No. 10869 - Four arithmetic operations

This article solves arithmetic problems using Java's basic arithmetic operations and output format.

한국어 원문은 여기에서 볼 수 있습니다.
[Java] Baekjun No. 10869 - Four arithmetic operations

BaekJoon 10869

Solution

1
2
3
4
5
6
7
8
9
10
11
12
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        
        int a = input.nextInt();
        int b = input.nextInt();
        
        System.out.printf("%d\n%d\n%d\n%d\n%d", a+b, a-b, a*b, a/b, a%b);
    }
}

Java output

When outputting from Java, if you want to use formatted output (%d, %f, etc.), you must use printf, not print.