본문 바로가기
Algorithm/Programmers

[Programmers] Lv.0 / PCCE / 4번 / 저축 / Java

by unknownomad 2024. 6. 18.

문제

 

풀이

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

 

출처

https://school.programmers.co.kr/learn/courses/30/lessons/250130

댓글