본문 바로가기

백준/JAVA

[Baekjoon/JAVA] 8370번 - Plane

Baekjoon Online Judge

문제로 이동

 

문제

Byteland Airlines recently extended their aircraft fleet with a new model of a plane. The new acquisition has n1 rows of seats in the business class and n2 rows in the economic class. In the business class each row contains k1 seats, while each row in the economic class has k2 seats.

Write a program which:

  • reads information about available seats in the plane,
  • calculates the sum of all seats available in that plane,
  • writes the result.

비즈니스 클래스에 n1열의 좌석이 있고, 각 열에는 k1개의 좌석이 있다. 이코노미 클래스에는 n2열의 좌석이 있고, 각 열에는 k2개의 좌석이 있다.

 

입력

In the first and only line of the standard input there are four integers n1, k1, n2 and k2 (1 ≤ n1, k1, n2, k2 ≤ 1 000), separated by single spaces.

공백으로 구분된 4개의 정수 n1, k1, n2, k2를 입력 받는다.

 

출력

The first and only line of the standard output should contain one integer - the total number of seats available in the plane.

총 좌석 수를 출력한다.

 


예제 입력 예제 출력
2 5 3 20 70

풀이

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n1 = in.nextInt(); // 열 수
        int k1 = in.nextInt(); // 열 당 좌석의 수

        int n2 = in.nextInt();
        int k2 = in.nextInt();

        System.out.println(n1 * k1 + n2 * k2);
    }
}