/****************************************************/ /* */ /* CSCI 121: Principles of Computer Programming */ /* Programming Project #5 */ /* Due Wednesday, February 16 */ /* Programmed by Ian Giese */ /* */ /****************************************************/ #include #include #include #include using namespace std; int main() { //Declare all the variables int numYears; double loanAmount, payment; ofstream output("output.lab5"); //Take input from keyboard user cout << "Input the loan amount: "; cin >> loanAmount; //Set up table output << "Repayment options for a loan of $" << fixed << showpoint << setprecision(2) << loanAmount << endl << endl << "Table shows " << "the total amount that will be repaid" << endl << endl << "Years" << right << setw(10) << "4.0%" << setw(11) << "4.5%" << setw(11) << "5.0%" << setw(11) << "5.5%" << setw(11) << "6.0%" << setw(11) << "6.5%" << setw(11) << "7.0%"; //Main program loop for(numYears = 1; numYears < 21; numYears++) { output << endl << setw(4) << numYears; //Calculate all of that will be repaid for(double intRate = 4; intRate < 7.1; intRate += 0.5) { payment = loanAmount * (((intRate/1200) * pow(1.0+(intRate/1200), numYears * 12.0)) / (pow(1.0+(intRate/1200), numYears * 12.0) - 1)); payment = payment * (numYears * 12.0); //Main output output << setw(11) << payment; } } cout << "Press enter to continue..."; cin.get(); return 0; }