inblog logo
|
sxias
    Programmers_CT

    [Programmers_CT] 12. 저축

    문정준's avatar
    문정준
    Feb 05, 2025
    [Programmers_CT] 12. 저축
    Contents
    1. 문제 설명 - 빈칸 채우기제한 사항2. 입출력 예시3. 코드 작성4. 테스트 실행5. 제출 후 채점
    💡
    프로그래머스 코딩 테스트 12. 저축

    1. 문제 설명 - 빈칸 채우기

    notion image

    제한 사항

    notion image

    2. 입출력 예시

    notion image
    notion image

    3. 코드 작성

    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); } }
    • 100만원을 모을 때 까지의 조건을 살펴봐야 함
      • 70만원 이전까진 매달 before만큼 저금
        • while (money < 70) { money += before; month++; }
      • 70만원을 넘긴 후 100만원까지는 매달 after만큼 저금
        • while (money < 100) { money += after; month++; }
     

    4. 테스트 실행

    notion image

    5. 제출 후 채점

    notion image
    Share article
    Contents
    1. 문제 설명 - 빈칸 채우기제한 사항2. 입출력 예시3. 코드 작성4. 테스트 실행5. 제출 후 채점

    Sxias ㆍ a32176740@gmail.com

    RSS·Powered by Inblog