I have to write a program that will calculate the monthly payment based on a total balance, APR, and finance period all of which are user inputs. My teacher gave us the equation payment = balance / (1 - (1 + interest)-n / interest). N is the number of months the finance period will last. Here's the catch; we are not allowed to use the math library to access exponents so I really have no clue what to do. He said something about using a loop but gave no specifics so I'm flying blind.
Create a function with parameters for a number and the exponent, then use a loop to multiply the number by itself however many times the exponent says.
I've done nothing as far as the math but here's what I've written.
////////////////////////////////
// Keenan Brown //
// Lab 2 //
// banker //
// 27 September 2012 ///
////////////////////////////////////////////////////////////////////////
// This program will calculate monthly payments //
// based on the total balance, annual percentage rate, //
// and the how long payments will be made in months. //
////////////////////////////////////////////////////////////////////////
# include <iostream> // Needed for stream I/O
# include <cstdlib> // Needed for system command, "clear"
# include <iomanip> // Needed for fixed decimal position
/////////////////////////////////////////////////////
// Display of user inputs and calculation //
////////////////////////////////////////////////////
cout << "\n\nPress ENTER to continue.";
cin.get( );
cin.ignore (1, '\n');
/////////////////////////////////////////////////////////////////
// Pauses program until user chooses to continue //
/////////////////////////////////////////////////////////////////