본문 바로가기
Beakjoon&프로그래머스/Java

[프로그래머스/Java] [PCCE 기출문제] 4번 / 저축

by 현장 2025. 2. 22.

-Code

import java.util.Scanner;

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

        int money = start;
        int month = 1;
        while (money < 70) {
            money += before;
            month++;
        }
        while (money < 100) {
            money += after;
            month++;
        }

        System.out.println(month);
    }
}