//Writen by Mo Kashi //This program does some mortgage calculations as folowing: //It prompts user to enter the principal of a mortgage,its //monthly payment,and its annual rate and prints out the //amount of principal at the end of the each year,the time //needed to pay off the mortgage and total interest paid. #include #include #include #include ofstream fout; int freeze; class Mortgage{ public: double getPrincipal(); double getMonthlyPayment(); double getAnnualRate(); void displayMortgageInfo(double,double,double); void Banner(); };//class Mortgage double Mortgage::getPrincipal(){//This method //prompts user to enter the amount of the principal and //this value.This method also prints out everything being //printed in Dos environment in the opened file A1Q2.txt double principal; cout<<"Enter in principal:\n"; cin>>principal; fout<<"Enter principal:\n"; fout<>monthlypayment; fout<<"Enter in monthly payment:\n"; fout<>annualrate; fout<<"enter in annual rate:\n"; fout<0){ principal=principal*monthlyfee; principal=principal-monthlyPayment; total_payment=total_payment+monthlyPayment; number_of_payments++; if(number_of_payments%12==0){ number_of_years++; if(principal<=0){ cout<<"End of year "<0&&monthlyPayment>0&&annualRate>0){ mortgageObj.displayMortgageInfo(principal,monthlyPayment,annualRate); principal=mortgageObj.getPrincipal(); monthlyPayment=mortgageObj.getMonthlyPayment(); annualRate=mortgageObj.getAnnualRate(); }//while }//main()