본문 바로가기

프로그래머스/lv0

양꼬치

/* 양꼬치
 * 양꼬치 가게는 10인분을 먹으면 음료수 하나를 서비스로 줍니다.
 * 양꼬치는 1인분에 12,000원, 음료수는 2,000원입니다.
 * 정수 n과 k가 매개변수로 주어졌을 때,
 * 양꼬치 n인분과 음료수 k개를 먹었다면 총얼마를 지불해야 하는지 return
 *
 * n    k   result
 * 10   3   124,000
 * 64   6   768,000
 */

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class programmer_0_46 {
    static int a1 = 10static int b1 = 3;
    static int a2 = 64static int b2 = 6;
    public int solution(int n, int k) {
        int answer = 0;
        if(n / 10 > 0){
            k = k - (n/10);
        }
        return 12000 * n + 2000 * k;
    }
    public static void main(String args[]){
        programmer_0_46 t = new programmer_0_46();
 
        System.out.println("---------------------------------------");
        System.out.println("result = " + t.solution(a1,b1));
        System.out.println("---------------------------------------");
        System.out.println("result2 = " + t.solution(a2,b2));
        System.out.println("---------------------------------------");
    }
}
cs

'프로그래머스 > lv0' 카테고리의 다른 글

각도기  (0) 2022.12.05
짝수의 합  (0) 2022.12.05
머쓱이보다 키 큰 사람  (0) 2022.12.05
중복된 숫자의 개수  (0) 2022.12.05
옷가게 할인받기  (0) 2022.12.05