Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ProjektEmerytura
- {
- public static void main(String[] args)
- {
- //Wprowadzenie danych.
- Scanner in = new Scanner(System.in);
- System.out.print("Ile pieniedzy potrzebujesz by przejsc na emeryture? ");
- double goal = in.nextDouble();
- System.out.print("Ile pieniedzy rocznie bedziesz wplacać? ");
- double payment = in.nextDouble();
- System.out.print("Jakie jest oprocentowanie w skali roku? ");
- double interestRate = in.nextDouble();
- double balance = 0;
- int years = 0;
- //Aktualizacja salda konta jesli cel nie jest osiagniety.
- while (balance < goal)
- {
- //Dodanie płatności i odsetek
- balance += payment;
- double interest = balance * interestRate / 100;
- balance += interest;
- years++;
- }
- System.out.println("Możesz przejść na emeryturę za " + years + "lat.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement