Bank interest calculation

Report a typo

When a bank has financial problems, the government can return a client's deposit if it is less than 700,000. The interest rate for a particular deposit is 7.1% a year. Interest is added to the same deposit at the end of the year, and then a new value of the interest is calculated. Find out how many years it will take for the sum of the deposit to exceed the value protected by the government.

The input format: the initial sum of the deposit.

It is guaranteed that the value will be between 50,000 and 700,000.

Please note that the deposit amount increases by a value proportional to the interest rate each year – in this case, 1.071 (7.1%). Thus, the formula for calculating the deposit amount will look like this: deposit = deposit * 1.071.

Sample Input 1:

650000

Sample Output 1:

2
Write a program in Kotlin
fun findYears(depo: Double): Int{
var deposit = depo
val interestRate = 1.071
val max = 700000
var years = 0
//
// implement the while loop here
//
return years
}
___

Create a free account to access the full topic