코딩테스트/lv0

[프로그래머스 코딩테스트] java Lv.0 저축 (PCCE 기출 문제 4번)

chantleman 2024. 6. 26. 14:48

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);
    }
}