| | |
Help with adding users
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 11
Reputation:
Solved Threads: 0
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'
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'
C++ Syntax (Toggle Plain Text)
// 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
Last edited by Ancient Dragon; Sep 1st, 2007 at 11:06 pm. Reason: add line numbers
exit? It's a reserved word for a standard function, and you have not declared it otherwise.
Work on your bracing.
Work on your bracing.
Last edited by Dave Sinkula; Sep 1st, 2007 at 10:46 pm.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Aug 2007
Posts: 11
Reputation:
Solved Threads: 0
I have made some changes. Here is the errors I am getting now. The good thing is I am getting less errors now.
1>------ Build started: Project: wk5Mortgage, Configuration: Debug Win32 ------
1>Compiling...
1>wk5m.cpp
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(59) : error C2059: syntax error : 'if'
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(78) : 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(79) : 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(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(83) : 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(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(87) : 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(155) : fatal error C1071: unexpected end of file found in comment
1>Build log was saved at "file://c:\Users\Keith\Documents\Visual Studio 2005\Projects\wk5Mortgage\wk5Mortgage\Debug\BuildLog.htm"
1>wk5Mortgage - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1>------ Build started: Project: wk5Mortgage, Configuration: Debug Win32 ------
1>Compiling...
1>wk5m.cpp
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(59) : error C2059: syntax error : 'if'
1>c:\users\keith\documents\visual studio 2005\projects\wk5mortgage\wk5mortgage\wk5m.cpp(78) : 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(79) : 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(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(83) : 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(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(87) : 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(155) : fatal error C1071: unexpected end of file found in comment
1>Build log was saved at "file://c:\Users\Keith\Documents\Visual Studio 2005\Projects\wk5Mortgage\wk5Mortgage\Debug\BuildLog.htm"
1>wk5Mortgage - 8 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
C++ Syntax (Toggle Plain Text)
// Week 5 Individual Assignment // Calculate the monthly payment, give users to have selection for yrs and interest rate. // Include header files #include <iostream> #include <iomanip> #include <cmath> using std::endl; using std::cin; using std::ios; //Namespaces using namespace std; //Declare and initialize variables double Amount; double 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 indic=false; char repeat; do { //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 (indic == 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"; //prompt for repeat cout<<setiosflags(ios::fixed)<<setprecision(2); system("pause"); cout << endl; system("cls"); cout <<"Month Balance Interest Paid"<<endl; cout <<"----- ------- -------------"<<endl; m=1; loanAmount=Amount; while (m <= mTerm) { //Math to figure out values for table cMnthInterest = loanAmount * mInterest; MnthAmount = MnthPayment - cMnthInterest; loanAmount = loanAmount - MnthAmount; //Table cout<<setw(4)<<m<<setw(15)<<"$"<<cMnthInterest<<setw(15)<<"$"<<loanAmount<<endl; // Controling the size length of text if(m % 12 == 0) system("pause"); system("cls"); cout <<"Month Balance Interest Paid"<<endl; cout <<"----- ------- -------------"<<endl; } m++; //assign user input value to control variable /*if (repeat == 'y' || repeat == 'Y') indic = true; { cout << endl <<"Thank you for using the Mortgage Calculator" << endl << endl; indic = false; } while(indic == true); return 0; } // end
Last edited by Ancient Dragon; Sep 2nd, 2007 at 9:35 pm. Reason: add line numbers
you need an opening brace { between lines 53 and 54 (or at the end of line 53 if that is your coding style) and remove the semicolon at the end of line 58.
lines 78, 81 and 85. values is a 2d array of doubles and you are attempting to use them as if it is a 1d array.
You really need to start reading the error messages better and try to figure out what's causing them. The first error message for any given line number is usually the most important as the compiler will spit out several other error messages as well.
lines 78, 81 and 85. values is a 2d array of doubles and you are attempting to use them as if it is a 1d array.
You really need to start reading the error messages better and try to figure out what's causing them. The first error message for any given line number is usually the most important as the compiler will spit out several other error messages as well.
Last edited by Ancient Dragon; Sep 2nd, 2007 at 9:42 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
>>Far as the lines I need to find out in Visual C++ 2005 express to display numbers to figure out which number line that is
Just click on the error message and the IDE will move the cursor to the correct line. Also the current line number is always displayed at the bottom of the window.
>>error C2181: illegal else without matching if
I already told you what that error was -- missing opening brace {.
Just click on the error message and the IDE will move the cursor to the correct line. Also the current line number is always displayed at the bottom of the window.
>>error C2181: illegal else without matching if
I already told you what that error was -- missing opening brace {.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Aug 2007
Posts: 11
Reputation:
Solved Threads: 0
Does this look right I am getting the same error?
C++ Syntax (Toggle Plain Text)
{ 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"; }
No it isn't correct. Read my post #5 very carefully, the very first sentence told you where to put that brace. If you count the braces in the code shipped you just posted you will see that there is an opening brace missing. The opening brace at the top of your last post is misplaced. Move it down to where I told you it belongs.
Last edited by Ancient Dragon; Sep 2nd, 2007 at 11:28 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Need Web Based Contact Us Form (PHP)
- WinXP User Accounts Issue (Windows NT / 2000 / XP)
- Questions about Hosting & Potentially Looking for a New Hosting Company (Web Hosting Deals)
- HTML question (JavaScript / DHTML / AJAX)
- adding printers win 2k (Windows NT / 2000 / XP)
- Networking in Windows (Networking Hardware Configuration)
- adding users to a domain (Win 2003) (Windows NT / 2000 / XP)
- USB port not responding on multi-accounts (Windows NT / 2000 / XP)
- tvtime and audio (*nix Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: meta-library for compile time matrix operations
- Next Thread: please help me!
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library linker list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






