Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rewriting a formula into a program

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have started the basic C++ program. One of my assignments is to write a program to calculate and pring the balance remaining after the first, second, and third monthly payment. The balance is a formula that I am having trouble putting into a simple C++ language.
This is the formula:
bal k = pmt [1 - (1 + i) k-n]/i

bal k = is the balance remaining after the kth payment k
k = is the payment number (1, 2, 3, ...)
pmt = amount of the monthly payment
i = interest rate per month
n = total number of payments to be made

In the (bal k) is the k is an exponent on the lower right hand of the bal. So in the book it shows bal, with a miniture k on the lower right hand of it.
Also the (k - n), within the formula, is an exponent of
(1 + i). How can I display the formula with the exponents beside them.
I suppose in the (bal k) it is suppose to display the balance and attached with a miniature (payment number) on the lower right hand of bal. I know this is probably confusing, if you do know what I am talking about, please remember I am a begginner in the application of C++. If you can, please teach me how and why you received the answer that you did. Thank you for your time.
 
in math.h you will find a funciton called pow which will raise a number to a power, or you could write your own function. That will take care of the value raised to the k-n power

for bal k I would use an array of size MAX_K where MAX_K = maximum number of balances... to access k zero you would just use array_name[0]. Loop on k so its readability is easier.

It also looks like you need to loop on i & n

I dont know the exact specifics of how you need to do this but this should get you started.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top