int main() { Mortgage first(10000, 5.0, 500) ; //uses non-default constructor Mortgage second ; //uses default constructor, mortage for $100,000 at 4.5% interest and $2,500 payment second.credit(10000) ; cout << "Current balance after rediting second mortgage 10K: " << second.getPrincipal() << endl ; cout << "Amortization schedule for first mortgage:" << endl ; first.amortize() ; }
int main() { Mortgage first; // using default constructor Mortgage second( 10000, 5, 500 ); // using non-default constructor cout << "\nError-check on invalid principal: "; Mortgage error1( -10000, 5, 500 ); // testing for error from invalid principal amount (negative) cout << "Error-check on invalid interest (below 0): "; Mortgage error2_1( 10000, -5, 500 ); // testing for error from invalid interest rate (below 0) cout << "Error-check on invalid interest (above 100): "; Mortgage error2_2( 10000, 105, 500 ); // testing for error from invalid interest rate (above 100) cout << "Error-check on invalid payment: "; Mortgage error3( 10000, 5, -500 ); // testing for error from invalid payment amount (negative) cout << "Error-check on multiple constructing invalidities: "; Mortgage error4( -100, -5, -50 ); // testing for multiple invalid inputs cout << "\nInitial principal of first mortgage: " << first.getPrincipal() << endl; first.credit( 10000 ); // credit the first mortgage with a $10000 payment cout << "Initial principal of a formerly invalid mortgage: " << error1.getPrincipal() << endl; error1.credit( 1000 ); cout << "\nPrincipal of the first mortgage after a $10000 credit: " << first.getPrincipal() << endl; cout << "Principal of the formerly invalid mortgage after a $1000 credit: " << error1.getPrincipal() << endl; cout << "Error-check on invalid credit: "; first.credit( -1000 ); // testing for error from invalid credit amount (negative) Mortgage error5( 0, 5, 5 ); cout << "Error-check on paid-off mortgage: "; error5.credit( 100 ); // testing for error when attempting to credit a mortgage that has been paid off cout << "\nAmortization table of the second mortgage:" << endl; second.amortize(); }
int main(){ Mortgage first(10000,5.0,500); //Normal mortgage Mortgage second; //Default constructor Mortgage bad(10000,-5,12); //Invalid mortgage (will give error message as soon as the program hits this line.) second.credit(10000); //Credits the second mortgage (reduces the total from $100,000 to $90,000 cout <<"Current balance after crediting second mortgage: "<<second.getPrincipal()<<endl; //Print this to the user cout<<"Amortization schedule for the first mortgage:"<<endl; first.amortize(); //Display the amortization table for the first mortgage. }
int main () { //create four new mortgages, one using default constructor, two display error message Mortgage one(300000,.01,3200);//this one will work cout << "Mortgage two: "; Mortgage two(100000,.5,200); //this one has a rate too large for the monthly payment and will display an error message cout << "Mortgage three: "; Mortgage three(100000,-2,500);//will display negative rate error Mortgage four; //default constructor, will have 100000 with 5% and $500 payment one.credit(50000);//This credits the first mortgage $50,000, will reduce initial principle to $250,000 cout << "Fourth mortgage balance: $" << four.getPrincipal() << endl; cout << "Current balance after crediting mortgage one 50K: $" << one.getPrincipal() << endl; cout << "Amortization schedule for first mortgage:" << endl; one.amortize(); }