I have to create the following functions with the code provided:

OpenScreen();
MonthlyPayment(???);
Amortize(???);
AmortizeScreenHeader(???);

But I'm kind of confused on whether or not the program will only have functions showing in the main body or will there be more than just the functions?

Ex:

int main
{
 OpenScreen()
 MonthlyPayment()
 Amortize()
 AmortizeScreenHeader()
}

Will the main body of the program look basically like this? or will it include more code including the functions?

#include<iostream>
#include<conio.h>
#include<math.h>
#include<iomanip>
#include<ctype.h>

using namespace std;

int main(void)
{
    float PVal, APR, I, MonthPay, MonthInst, Princ, Balance;
    int Years, N, AmYr;
    char Usresp, ch;
    
    do
    {
         system("CLS");
         cout << "\n\n";
         cout << "\n         **********************************************";
         cout << "\n         *      PAYMENT FINDER WITH AMORTIZATION      *";
         cout << "\n         *                    by                      *";
         cout << "\n         *                    Name                    *";
         cout << "\n         *                                            *";
         cout << "\n         **********************************************\n";
         cout << "\n            Enter Principal Value of Loan: ";
         cin >> PVal;
         cout << "     Enter Annual Interest Rate (7.5, 8): ";
         cin >> APR;
         cout << "               Enter Years to Repay Loan: ";
         cin >> Years;
         
         if ((PVal !=0) || (APR != 0) || (Years != 0))
         {
            I = APR / 1200;
            N = Years * 12;
            MonthPay = (PVal * I) / (1 - pow(1 + I, -N));
            cout << setprecision(2);
            cout << fixed << showpoint;
            
            cout << "\n\n  Monthly Payment\tTotal Paid\tTotal Interest";
            cout << "\n------------------------------------------------------------\n";
            cout << setw(13) << MonthPay << setw(20) << MonthPay * N
                 << setw(20) << (MonthPay * N) - PVal << endl;
            cout << "\n\nWould you like to see this Loan Amortized? (Y or N): ";
            Usresp = getch();
            if (toupper(Usresp) == 'Y')
            {
                AmYr = 1;
                system("CLS");
                cout << "\n                         YEAR " << AmYr << endl;
                cout <<  "\nMonth      Payment      Principal       Interest       Balance";
                cout << "\n--------------------------------------------------------------\n";
                Balance = PVal;
                for (int j = 1; j <=N; j++)
                {
                    Usresp = ' ';
                    MonthInst = MonthPay * (1 - ((pow((1 + I),(j - N))) / I) + ((pow((1 + I), ((j - 1) - N ))) / I));
                    Princ = MonthPay - MonthInst;
                    Balance = Balance - Princ;
                    cout << setprecision(2);
                    cout << fixed << showpoint;
                    cout << setw(3) << j << setw(15) << MonthPay << setw(15)
                         << Princ << setw(15) << MonthInst << setw(14) << Balance << endl;
                    if (j == N) break;
                    if (j % 12 == 0)
                    {
                        cout << "\n\n\n  Press c - Continue         x - Exit \n";
                        ch = toupper(getch());
                        while (ch != 'C' && ch != 'X')
                        {
                              ch = toupper(getch());
                        }  
                        if (ch == 'C')
                        {
                            AmYr = AmYr + 1;
                            system("CLS");
                            cout << "\n                          YEAR " << AmYr << endl;
                            cout <<  "\nMonth      Payment       Principal       Interest      Balance";
                            cout << "\n--------------------------------------------------------------\n";
                        }
                        else if (ch == 'X') break;
                    }
                }      
            }                                         
       }
       cout <<  "\n\nWould you like to do another? (Y or N): ";
       Usresp = getch();
       
    }while (toupper(Usresp) != 'N');
}

It shouldn't all be crammed into main() like your code example, according to your assignment. Your main() will have your variable declarations and other such housekeeping, but it will be closer to what you put forth in your "Ex".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.