Skip to content
Exercise · Variables and types · lesson 9 of 9

Exercise: a three-year deposit

At the end of every year the bank adds percent percent of the amount that is in the deposit at that moment. Write a function function deposit(amount, percent) that returns the amount in the deposit after three years if amount rubles were put in at the start. For example, 1000 rubles at 10 percent become 1100 after one year, 1210 after two and 1331 after three.

  • deposit(1000, 10) → 1331
  • deposit(200, 50) → 675
  • deposit(1000, 5) → 1157.625

Constraints: amount and percent are whole numbers, amount from 0 to 10000, percent from 0 to 100; the result is compared with the expected one to within 0.000000001, as in the Fahrenheit exercise.

Do not add extra imports unless the task says so explicitly.

deposit.js — javascript
javascript · 4 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way