3초기억력

자바기초)Variable + 값입력 중급문제1 본문

자바_기초

자바기초)Variable + 값입력 중급문제1

잠수콩 2019. 5. 14. 08:36
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
import java.util.Scanner;

public class exam2_Variable {

	public static void main(String[] args) {

		System.out.println("대출 상환금 계산 서비스에 오신걸 환영합니다.");
		System.out.print("대출원금이 얼마인가요? 백만원 이상만 계산해드립니다. ");

		Scanner sc1 = new Scanner(System.in);
		int p = sc1.nextInt();

			if (p < 1000000) {
				System.out.println("대출원금은 백만원 이상 입력하세요.");
			
			} else {
				
				System.out.print("상환기간은 몇년인가요? ");
				
				Scanner sc2 = new Scanner(System.in);
				int y = sc2.nextInt();

				System.out.print("이자율은 몇%인가요? ");
				
				Scanner sc3 = new Scanner(System.in);
				double r = sc3.nextDouble();
				
				r = r * 0.01;
				
				double d1, d2;
				d1 = (double)Math.pow(1 + r, y) * p * r;				
				d2 = (double)Math.pow(1 + r, y) - 1;
				
				int d = (int)(d1 / d2);
				
				System.out.println();
				System.out.println("대출 상환금 내역을 알려드리겠습니다.");
				System.out.println("1년에 한번씩 상환하신다면 매년 "+ d +"원씩 지불하셔야 합니다.");
				System.out.println("1달에 한번씩 상환하신다면 매년 "+ (d / 12) +"원씩 지불하셔야 합니다.");
				System.out.println("상환완료시까지 총 상환금액은 " + (d * y) + "원 입니다.");
				
				System.out.println("저희 서비스를 이용해주셔서 감사합니다. 또 들려주세요.");	
				
			}


		
		
		
	}

}
Comments