C++ Programming Code won't work!!

[code]
/*
Week 4 Individual Assignment


Class: C++ PROGRAMMING II PRG/411
Assignment:
SR-mf-003 Change Request #14
Write the program as an object-oriented C++ program that allows the user to select which way they want
to calculate a mortgage: by input of the amount of the mortgage, the term of the mortgage, and the interest
rate of the mortgage payment or by input of the amount of a mortgage and then select from a menu of mortgage
loans:

- 7 year at 5.35%
- 15 year at 5.5%
- 30 year at 5.75%.

In either case, display the mortgage payment amount. Then, list the loan balance and interest paid for each payment
over the term of the loan. On longer term loans, the list will scroll off the screen. Do not allow the list to scroll
off the screen, but rather display a partial list and then allow the user to continue the list. Allow the user to loop
back and enter a new amount and make a new selection, or quit. Insert comments in the program to document the
program
*/

#include "math.h"
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;


using std::cout;
using std::endl;
using std::cin;


//This will define the classes for which Obeject Oriented Program tools will be used. There is no need for private
//classes since everything should be public.

class Mortgage4 //class is defined

{

public: //this allows public access
void header(); //Intro
void enterprinc(); //This is where the principle is entered


double princ; //principle of the loan
double anInt; //Interest of the loan
int yrs; //Term of the loan
};

//This declares all the functions within the class
//These functions will be what is displayed on the screen to prompt the user.

void Mortgage4::header() //This is the Funtion for the header of the program.
{

cout << "Week 4 Individual Assignment C++ Mortgage Calculator\n\n";
cout << endl;
cout << "By Jason Martin\n\n";
cout << endl;

}

void Mortgage4::enterprinc ()//This is the Function for the user to enter the principle of the loan.
{
cout << endl;
cout << "Enter the amount for the Loan:$"; //User enters amount for the Loan
cin >> princ;

}



int main ()

{

Mortgage4 mortgageTotal;

double princ = 0; //*Principle amount of loan is entered by user
double anInt []= {5.35, 5.5, 5.75,};//*Annual interest rate choosen in scenario
double yrs []= {7, 15, 30,}; //*Term of the loan is choosen with scenario
double anInt = 0;//Entered Rates
double yrs =0;//Entered Term
double pmt = 0; //*Monthly Payment
double intPd; //*Interest Paid
double bal; //*Loan Balance
double amtPd; //*Amount Paid on Loan
double check(int min, int max);
int NOP; //*Number of Payments
int Mnth; //*Allows loop for loan balance and interest paid
int SL = 0; //*Scroll List for loan balance and interest paid
char indicator = ('A' ,'a','B','b','R','r'); //User chooses to enter Int and term or select scenario




//Begin Loop

{
mortgageTotal.header ();
mortgageTotal.enterprinc ();


cout<< "Would you like to select a scenario or enter your choice?"<< endl;
cout<< "Press A to select your scenario, or B to enter your choices"<<endl;
cin >> indicator;

if (indicator == 'A','a')
{

cout << "Please select your Terms and Rates from the following choices: " << endl;
cout << "1. 7 years at 5.35%" << endl;
cout << "2. 15 years at 5.5%" << endl;
cout << "3. 30 years at 5.75%" << endl;
cout << endl;

cout << "What is your selection:";

int select;
cin >> select;
cout << endl << endl << endl;
switch (select)
{

case 0: cout << endl;
break;
case 1:
yrs[1] = 7;
anInt[1] = 5.35;
cout << "You have selected 7 Years and 5.35%" << endl;
break;

case 2:
yrs[2] = 15;
anInt[2]= 5.50;
cout << "You have selected 15 Years at 5.50%" << endl;
break;

case 3:
yrs[3] = 30;
anInt[3] = 5.75;
cout << "You have selected 30 Years at 5.75%" << endl;
break;

default:
cout << "Invalid Line Number" << endl;
if ((select < 1)|| (select > 3))

{
system("cls");
cout << "Please enter a valid choice!!!";
system("PAUSE");

system("cls");
return main();
}
}
}
if (indicator == 'B','b')

{
cout << "Enter Rate:" << endl;
cin >> anInt;

cout << "Enter Term:" << endl;
cin >> yrs;
}

//Formula to calculate monthly payment

double pmt = (mortgageTotal.princ*((anInt[]/1200)/(1 - pow((1+(anInt[]/1200)),-1*(yrs[]*12)))));

//Ouput payment

cout << "The Following is your answer based on the amount you have entered: \n";
cout << endl;
cout << "Your Monthly Payment is: $" << pmt << "\n";
cout << endl;


//Remaining Formulas for Number of Payments,
double NOP = yrs [] * 12;
SL = 0;

for (Mnth = 1; Mnth <= NOP; ++Mnth)
{

//Formula
intPd = mortgageTotal.princ * (anInt[] / 1200);
amtPd = pmt - intPd;
bal = mortgageTotal.princ - amtPd;

if (bal < 0)bal = 0;
mortgageTotal.princ = bal;


//This will give the Scroll List titles to seperate the loan balance and Interest paid

if (SL == 0)

{
cout << "Balance of Loan" << "\t\t\tAmount of Interest Paid" << endl;

}

cout << setprecision(2) << fixed << "$" << setw(5) << bal << "\t\t\t\t$"<< setw(5) << intPd << endl;
++SL;


/*Allows the user to enter a letter to see the remaining information after 12 lines,
to clear the list and enter new values, or to quit.

*/

if (SL == 12)

{
cout << "Would you like to continue and see the rest of the information or Quit?\n";
cout << endl;
cout << "Enter 'R' to see the remainder, Enter 'C' to try another example, Enter 'D' for done.\n";
cin >> indicator;

if

(indicator == 'R','r')SL = 0;

else

if

(indicator == 'C', 'c')
break;

else
if
(indicator == 'D','d')
cout << endl;

}

}

}

while ((indicator!='C')&&(indicator!='c'));

//Exit the program

return 0;

}

[\code]
If you want anyone to help you, you should probably tell us what the problem is, fix your code tags, and indent your code properly.
Few suggestions
1. Similar to other methods, create a method
 
double calculateMonthlyPayment(); 

in the class so that you can reuse it all the time. You can use a switch statement to assign different interest rates in this method.
2. create a member
 
double monthlyPayment;
in the class and this value is assigned by the return value of method in 1.
3. In side the method void Mortgage4::enterprinc (), also include statements for a user input for the number of years.This makes all the user input calls in oneplace

The above three suggestion will make your main neat and readable. It may look like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main(){
Mortgage4 mortgageTotal;
// call the methods in the order
mortgageTotal.header ();
mortgageTotal.enterprinc ();
double EMI= mortgageTotal.calculateMonthlyPayment(); 

cout << "Your monthly payment is" << EMI << "\n";
// OR
cout << "Your monthly payment is"<<mortgageTotal.monthlyPayment << "\n";


return 0;
}



Topic archived. No new replies allowed.