Hey, everyone. I am having getting my code to work. I have tried to add in a selection for the users. Not to mention I think I broke my table.
here is the errors I get.
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(51) : error C2446: '!=' : no conversion from 'int' to 'void (__cdecl *)(int)'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(51) : error C2040: '!=' : 'void (__cdecl *)(int)' differs in levels of indirection from 'int'
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(51) : error C2446: '!=' : no conversion from 'int' to 'void (__cdecl *)(int)'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(51) : error C2040: '!=' : 'void (__cdecl *)(int)' differs in levels of indirection from 'int'
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(62) : error C2317: 'try' block starting on line '53' has no catch handlers
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(62) : error C2181: illegal else without matching if
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(62) : warning C4390: ';' : empty controlled statement found; is this the intent?
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(81) : error C2440: '=' : cannot convert from 'double [2]' to 'float'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(82) : error C2440: '=' : cannot convert from 'double [2]' to 'double'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(85) : error C2440: '=' : cannot convert from 'double [2]' to 'float'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(86) : error C2440: '=' : cannot convert from 'double [2]' to 'double'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(89) : error C2440: '=' : cannot convert from 'double [2]' to 'float'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(90) : error C2440: '=' : cannot convert from 'double [2]' to 'double'
1> There is no context in which this conversion is possible
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(139) : error C2446: '==' : no conversion from 'int' to 'char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(139) : error C2040: '==' : 'char *' differs in levels of indirection from 'int'
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(139) : error C2446: '==' : no conversion from 'int' to 'char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(139) : error C2040: '==' : 'char *' differs in levels of indirection from 'int'
// Week 5 Individual Assignment
// Calculate the monthly payment
// Include header files
#include <iostream>
#include <iomanip>
#include <math.h>
using std::cout;
using std::endl;
using std::cin;
using std::ios;
//Namespaces
using namespace std;
//Declare and initialize variables
double Amount;
float Term;
double Interest;
double MnthPayment;
double rPayments;
double newAmount;
double loanPrinciple;
double loanAmount;
double cMnthInterest;
double MnthAmount;
int m = 0;
double values[3][2] = {{7, 5.35},{ 15, 5.5},{30, 5.75}};
int main()
{
double mInterest;
double mTerm;
int select;
bool valid = false;
char repeat;
while (exit != 'y' && exit != 'y')
try {
//Data Entry
cout << "Loan Amount: ";
cin >> Amount;
if (!(cin>> Amount))
cin.clear();
cin.ignore(500,'\n');
throw "Invalid number";
}
else if (Amount >1000000 || Amount < 1);{
cin.clear();
cin.ignore(500, '\n');
throw "Please enter up to 1000000";
}
cout << endl << "Interest rate choices"; //interest menu
cout << endl << "1. 7 yrs at 5.35%" << endl;
cout << endl << "2. 15 yrs at 5.50%" << endl;
cout << endl << "3. 30 yrs at 5.75%" << endl;
//start of loop for interest
while (valid == false) {
cout << "\n Enter your selection: ";
cin >> select;
if (( select = 1) || (select == 2) || (select == 3)){
}
// variable input for user select
switch (select) {
case 1:
Term = values[0];
Interest = values[1];
break;
case 2:
Term = values[2];
Interest = values[3];
break;
case 3:
Term = values[4];
Interest = values[5];
break;
}
//cout << endl<< Fetching <<endl << endl;
mInterest = Interest/(12*100);
mTerm = Term * 12;
// Calculate the payment
MnthPayment = (Amount * pow((1 + mInterest), mTerm)* mInterest)/(pow((1 + mInterest),mTerm)-1.0);
// Print out for calculations
cout << "The mortgage payment:$" << MnthPayment <<"\n";
while (m < rPayments)
//Math to figure out values for table
MnthPayment = Interest * mInterest;
Amount = MnthPayment - cMnthInterest;
newAmount = loanPrinciple - MnthAmount;
loanAmount = newAmount;
// Controling the size length of text
if(m % 12 == 0)
{
cout<<"Enter to continue";
cin.get();
cout<<endl<<endl;
cout<<setw(18)<<"Interest";
cout<<setw(21)<<"New Principle"<<endl<<endl;
m++;
//Table
cout<<setw(4)<<m;
cout<<setw(20)<<setiosflags(ios::fixed)<<setprecision(2)<<cMnthInterest<<setw(22)<<loanAmount<<endl;
}
//prompt for repeat
cout <<"Would you like to calculate another loan?" << endl
<<"Please enter Y to repeat or any other key to exit: ";
cin >> repeat;
cout << endl;
//assign user input value to control variable
if (repeat == 'y' || repeat == 'Y') valid = true;
else
{
cout << endl <<"Thank you for using the Mortgage Calculator"<< endl << endl;
valid = false;
}
}
while(valid == true);
return 0;
}
// end