Compound interest

Compound interest

How savings in a bank account grows with interest.

Compound interest, also known as compounding, is when you earn money (interest) on both the money you save and the interest you earn on that saving. So every year when you earn interest, you also earn interest on the interest itself.

Make


Write a program that outputs the balance each year from three inputs: the balance in pounds sterling, the percentage interest rate and the target balance to achieve. The program stops when the target balance is reached.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called `compound` that:

  1. Calculates a new balance from the current balance plus the amount earned from the interest. E.g. If the amount is £1000 and the annual interest rate is 3% then 3% of 1000 is 30, so the new balance would be £1030.
  2. Outputs the balance each year until the target balance is met or exceeded.

Hint: `interest_rate = interest_rate / 100` will convert the interest rate into a number you can multiply by the balance to calculate the new balance.

Complete the `main program` so that:

  1. The user can input the balance to the nearest pound.
  2. The user can input the interest rate as a percentage.
  3. The user can input the target balance to achieve.

Typical inputs and outputs from the program would be:

Enter the balance to the nearest pound: £1000

Enter the % interest rate: 3

Enter the target balance to the nearest pound: £1300

Year 1 : Balance £ 1030

Year 2 : Balance £ 1060

Year 3 : Balance £ 1091

Year 4 : Balance £ 1123

Year 5 : Balance £ 1156

Year 6 : Balance £ 1190

Year 7 : Balance £ 1225

Year 8 : Balance £ 1261

Year 9 : Balance £ 1298

Year 10 : Balance £ 1336

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run the unit tests below to check that your program has met the success criteria.

Enter the balance to the nearest pound: £5000

Enter the % interest rate: 4

Enter the target balance to the nearest pound: £8000

Year 1 : Balance £ 5200

Year 2 : Balance £ 5408

Year 3 : Balance £ 5624

Year 4 : Balance £ 5848

Year 5 : Balance £ 6081

Year 6 : Balance £ 6324

Year 7 : Balance £ 6576

Year 8 : Balance £ 6839

Year 9 : Balance £ 7112

Year 10 : Balance £ 7396

Year 11 : Balance £ 7691

Year 12 : Balance £ 7998

Year 13 : Balance £ 8317

Enter the balance to the nearest pound: £100

Enter the % interest rate: 2

Enter the target balance to the nearest pound: £110

Year 1 : Balance £ 102

Year 2 : Balance £ 104

Year 3 : Balance £ 106

Year 4 : Balance £ 108

Year 5 : Balance £ 110

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.