Can someone please help me with this program. These are my instructions that were given to me... When I finish the inputs and it comes back with the numbers the payment amount is wrong
///////////////////////////////////////////////////////////////////////////////
//
// Name: GCD.cpp
// Author: Jeffrey A. Stone
// Course: CMPSC 101/121
// Purpose: Computes the GCD of two integers.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Header Files...
///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
///////////////////////////////////////////////////////////////////////////////
// Namespaces used....
///////////////////////////////////////////////////////////////////////////////
using namespace std;
///////////////////////////////////////////////////////////////////////////////
// Type Definitions...
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Function prototypes...
///////////////////////////////////////////////////////////////////////////////
double inputPrincipal();
// input a simple integer from the user
double inputAIR();
// input a simple integer from the user
int inputTOF();
// input a simple integer from the user
int inputPPY();
// input a simple integer from the user
double computeAmortizedPayment( double p, double ir, double ppy, int n);
// compute for the Amortized Payment
void printHeaderInformation(double princ, double ir, double amort, int n);
// display summary information
double computeInterestPortion(double remaining_balance, double ir, int ppy);
// computes the interest of each individual payment
void computeAndPrintRows(double p, double ir, double amort, int n, int ppy);
// computes and displays the payment schedule for the loan
///////////////////////////////////////////////////////////////////////////////
// Constants...
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION NAME: main
// PARAMETERS: None
// RETURN TYPE: int
// PURPOSE: Entry point for the application.
//
///////////////////////////////////////////////////////////////////////////////
int main()
{
double p = 0.0; // declare a variable to store an input value
double ar = 0.0; // declare a variable to store an input value
int t = 0; // declare a variable to store an input value
int py = 0; // declare a variable to store an input value
double a = 0.0; // stores the amortized payment
p = inputPrincipal(); // input the Principal
ar = inputAIR(); // input the Annual Interest Rate
t = inputTOF(); // input the Term of the Loan
py = inputPPY(); // input the Payments per Year
// compute the Amortized Payment
a = computeAmortizedPayment( p, ar, t, py );
// output the value...
printHeaderInformation( p, ar, t, py );
cout.precision(2);
// exit the program with success (0 == success)
return 0;
}
double inputPrincipal()
{
double num = 0.0; // stores the user input value
bool is_valid_input = false; // flag variable
while ( is_valid_input == false ) // !is_valid_input
{
cout << "Please enter an Principal that is > 0 "; // prompt
cin >> num; // input
// check to see if the user entered a valid value...
if ( num > 0 )
{
// set the flag variable...
is_valid_input = true;
}
else
{
// alert the user...
cout << "ERROR: The Principal must be greater than zero (0)." << endl;
}
}
// return the user input value...
return num;
}
double inputAIR()
{
double rate = 0.0; // stores the user input value
bool is_valid_input = false; // flag variable
while ( is_valid_input == false ) // !is_valid_input
{
cout << "Please enter a Annual Interest Rate that is in the range of [1-100] "; // prompt
cin >> rate; // input
// check to see if the user entered a valid value...
if ( rate > 1 && rate <= 100 )
{
// set the flag variable...
is_valid_input = true;
}
else
{
// alert the user...
cout << "ERROR: The AIR has to be [1-100]" << endl;
}
}
// return the user input value...
return rate;
}
int inputTOF()
{
int loan = 0; // stores the user input value
bool is_valid_input = false; // flag variable
while ( is_valid_input == false ) // !is_valid_input
{
cout << "Please enter a Term of the Loan that is in the range of [10-30] "; // prompt
cin >> loan; // input
// check to see if the user entered a valid value...
if ( loan > 10 && loan <= 30 )
{
// set the flag variable...
is_valid_input = true;
}
else
{
// alert the user...
cout << "ERROR: The TOF has to be [10-30]" << endl;
}
}
// return the user input value...
return loan;
}
int inputPPY()
{
int pay = 0; // stores the user input value
bool is_valid_input = false; // flag variable
while ( is_valid_input == false ) // !is_valid_input
{
cout << "Please enter a Payments per Year that is in the range of [1-12] "; // prompt
cin >> pay; // input
// check to see if the user entered a valid value...
if ( pay > 1 && pay <= 12 )
{
// set the flag variable...
is_valid_input = true;
}
else
{
// alert the user...
cout << "ERROR: The PPY has to be [1-12]" << endl;
}
}
// return the user input value...
return pay;
}
double computeAmortizedPayment( double p, double ir, double ppy, int n)
{
double a = 0.0;
a = (p * ir * pow( (ir+1) , n) ) / (pow( (ir+1) , n ) - 1 );
return a;
}
void printHeaderInformation(double princ, double ir, double amort, int n)
{
cout << "\nBeginning Principal: " << princ << endl;
cout << "Annual Interest Rate: " << ir << endl;
cout << "Total Payments: " << n << endl;
cout << "Payment Amount: " << amort << endl;
// output the column headings...
cout << setw(5) << "\nPayment#" << setw(20) << "Interest Due" << setw(20) << "Principal" << setw(25) << "Balance Remaining" << endl;
}
double computeInterestPortion(double remaining_balance, double ir, int ppy)
{
// compute the interest portion of the payment...
return (remaining_balance * (ir / 100.0)) / ppy;
}
void computeAndPrintRows(double p, double ir, double amort, int n, int ppy)
{
}