Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class App {
- public static void main(String args[]) {
- double n, p, s = 0;
- int y;
- Scanner in = new Scanner(System.in);
- System.out.print("Введите сумму кредита: ");
- n = in.nextDouble();
- System.out.print("Введите срок кредита в годах: ");
- y = in.nextInt();
- System.out.print("Введите процент по кредиту: ");
- p = in.nextDouble();
- System.out.println();
- in.close();
- p /= 100;
- p /= 12;
- double principalPayment = n / (12 * y);
- for (int year = 0; year < y; year++) {
- for (int month = 0; month < 12; month++) {
- double percent = n * p;
- double m = percent + principalPayment;
- n -= principalPayment;
- s += m;
- System.out.printf("Год %d, месяц %d, выплата: %.2f\n", year + 1, month + 1, m);
- }
- }
- System.out.printf("Суммарная выплата по кредиту: %.2f", s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement