Click here to Skip to main content
15,170,741 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need to write a C++ program that calculates the monthly balance of a debt.

It should kinda look like this:

Starting balance: 1000
Interest rate (APR): 8
Monthly payment: 100

Month Payment Interest Balance
1 100.00 6.67 906.67
2 100.00 6.04 812.71
3 100.00 5.42 718.13
4 100.00 4.79 622.92
5 100.00 4.15 527.07
6 100.00 3.51 430.58
7 100.00 2.87 333.45
8 100.00 2.22 235.68
9 100.00 1.57 137.25
10 100.00 0.91 38.16
11 38.42 0.25 0.00

Total amount paid: 1038.42

What I have tried:

I need help starting it and writing it
Updated 24-Feb-17 18:30pm
[no name] 24-Feb-17 23:12pm
Here's your start
int main()
// fill in the rest of your code here

In addition to the previous comments, I offer this...

Break the problem down into 'bite size pieces'.

You need, for example

a) code/a routine to get

Starting balance: 1000
Interest rate (APR): 8
Monthly payment: 100

from the user - what do you know that can do this ?

in the most basic method, you

cout << "some message for the user, maybe, type a number and press enter"
int someVarCalledI = 0;
cin >> someVarCalledI;

but if you're going to do that 3 times you may as well write a function to take the 'message for the user' and return a value (be careful what numeric type you are using here)

b) You need code to calculate the monthly balance for month n

c) You need code to output the results of the monthly balance

d) possibly some sort of loop to combine b & c
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.

An interesting link to get you started on a new project: Systems development life cycle - Wikipedia[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900