NLKappa

Schoolwork 2

Sep 28th, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner (System.in);
  7.  
  8.  
  9.         System.out.println("Введите сколько вы вкладываете: ");
  10.         double money = sc.nextInt();
  11.         System.out.println("Введите процент банка: ");
  12.         double perc = sc.nextInt();
  13.         int year = 0;
  14.         System.out.println("Введите сколько вам нужно денег: ");
  15.         int money2 = sc.nextInt();
  16.         while (money < money2) {
  17.             money += money * perc / 100;
  18.             money = Math.floor(money * 100);
  19.             money /= 100;
  20.             year++;
  21.         }
  22.         System.out.printf("Вам нужно %d лет.", year);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment