Привет , срам - не срам, бих искал да ви задам един въпрос относно задача 7 “interest” от “data types and variables” . (Java Qa)
You have deposited a sum into your bank account for 3 years.
The bank has announced an interest of 5% per year. Each time the interest is calculated and added to your deposit. You have to calculate the amount in your deposit for each year.
Input
On the only line you will receive a number (n) with the sum deposited
Output
You should print the amount in your deposit for each of the 3 years.
input 100, output съответно
105.00
110.25
115.76
Надали има проблем със задачата , не мога да се досетя, как се пресмята така, че да са 110.25, 115.76. Благодаря предварително.
Съответно Scanner scanner = new Scanner (System.in);
String line = scanner.nextLine();
int num = Integer.parseInt(line);
double sum = num * 1.05;
double second = sum * 1.05;
double third = second * 1.05;
System.out.printf("%.2f",sum);
System.out.printf("%.2f", second);
System.out.printf("%.2f", third);