Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class App {
  4.    
  5.     public static void main(String args[]) {
  6.         double n, p, s = 0;
  7.         int y;
  8.        
  9.         Scanner in = new Scanner(System.in);
  10.        
  11.         System.out.print("Введите сумму кредита: ");
  12.         n = in.nextDouble();
  13.        
  14.         System.out.print("Введите срок кредита в годах: ");
  15.         y = in.nextInt();
  16.        
  17.         System.out.print("Введите процент по кредиту: ");
  18.         p = in.nextDouble();
  19.         System.out.println();
  20.        
  21.         in.close();
  22.        
  23.         p /= 100;
  24.         p /= 12;
  25.        
  26.         double principalPayment = n / (12 * y);
  27.        
  28.         for (int year = 0; year < y; year++) {
  29.             for (int month = 0; month < 12; month++) {
  30.                 double percent = n * p;
  31.                 double m = percent + principalPayment;
  32.                
  33.                 n -= principalPayment;
  34.                 s += m;
  35.                
  36.                 System.out.printf("Год %d, месяц %d, выплата: %.2f\n", year + 1, month + 1, m);
  37.             }
  38.         }
  39.        
  40.        
  41.         System.out.printf("Суммарная выплата по кредиту: %.2f", s);
  42.     }
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement