Join 137,395 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,119 people online right now. Registration is fast and FREE... Join Now!
count++; } cin.get(); // Wait for keypress before exiting. cin.get(); // Wait for keypress before exiting. return 0; }
// get price of vehicle void getPrice (int & price) { while ( price < 50000.00|| price > 0)
{ cout << "Enter the price of the Vehicle: "; cin >> price; if (price > 50000.00) cout << "Enter a price less than 50.\n"; if (price < 50.00) cout << "Enter a price less that 50000.\n"; } return; } // get tile size in inches void getInterestRate( float& annualIntRate, float& annualIntPercent, float& monIntRate);
{
while (annualIntRate >= 0 || annualIntRate > .50) { cout << "Enter the annual interest rate in decimals "; cin >> annualIntRate; if (.50 < annualIntRate < 0) cout << "Enter a number less than .50 and greater than 0.\n"; } return; } } // getdownPayment: Prompts the user for the downPayment void getdownPayment(float& downPayment); {
bool dataInvalid = true; // Start with invalid data to begin the while loop
// Get our downPayment // while(dataInvalid) { cout << "enter the down payment "; cin >> downPayment if (downPayment < 0) { cout << "------ Positive Values Only, reenter data. --------\n"; dataInvalid = true;
{ dataInvalid = false; } } dataInvalid = true; // Start off invalid so the loop will execute // Get our down payment check for errors
while(dataInvalid) }
return;
} // get trade in value void gettradeIn( float& tradeIn); { while (tradeIn >= 0) { cout << "Enter the value of the trade in "; cin >> tradeIn; if ( annualIntRate < 0) cout << "Enter a number greater than 0.\n"; } return; } // calculate the monthly payment for vehicle void calcmonPayment(float price, float downPayment, float tradeIn, float noMos, float monPayment, float loanAmt);
count++; } cin.get(); // Wait for keypress before exiting. cin.get(); // Wait for keypress before exiting. return 0; }
// get price of vehicle void getPrice (int & price) { while ( price < 50000.00|| price > 0)
{ cout << "Enter the price of the Vehicle: "; cin >> price; if (price > 50000.00) cout << "Enter a price less than 50.\n"; if (price < 50.00) cout << "Enter a price less that 50000.\n"; } return; } // get tile size in inches void getInterestRate( float& annualIntRate, float& annualIntPercent, float& monIntRate);
{
while (annualIntRate >= 0 || annualIntRate > .50) { cout << "Enter the annual interest rate in decimals "; cin >> annualIntRate; if (.50 < annualIntRate < 0) cout << "Enter a number less than .50 and greater than 0.\n"; } return; } } // getdownPayment: Prompts the user for the downPayment void getdownPayment(float& downPayment); {
bool dataInvalid = true; // Start with invalid data to begin the while loop
// Get our downPayment // while(dataInvalid) { cout << "enter the down payment "; cin >> downPayment if (downPayment < 0) { cout << "------ Positive Values Only, reenter data. --------\n"; dataInvalid = true;
{ dataInvalid = false; } } dataInvalid = true; // Start off invalid so the loop will execute // Get our down payment check for errors
while(dataInvalid) }
return;
} // get trade in value void gettradeIn( float& tradeIn); { while (tradeIn >= 0) { cout << "Enter the value of the trade in "; cin >> tradeIn; if ( annualIntRate < 0) cout << "Enter a number greater than 0.\n"; } return; } // calculate the monthly payment for vehicle void calcmonPayment(float price, float downPayment, float tradeIn, float noMos, float monPayment, float loanAmt);
configure your function. I mean function first before the main.
then can you post the your problem with the specific lines of code thats had errors.
>If you get C4244, you should either change your program to use compatible types, or add some logic to your code, to ensure that the range of possible values will always be compatible with the types you are using.
>An open brace occurs at global scope without a corresponding function header.This error can be caused by an old-style C++-language formal list.
>C3209....'class' : generic class must be a managed class A generic class must be a managed class.
>C2059 To determine the cause, examine not only the line listed in the error message, but also the lines above it. The following example generates an error message for the line declaring j, but the true source of the error appears on the line just above it.
If examining the lines yields no clue to what the problem might be, try commenting out the line listed in the error message and possibly several lines above it.
Try....to examine your braces.....you might forgot to close a function or a syntax
configure your function. I mean function first before the main.
then can you post the your problem with the specific lines of code thats had errors.
>If you get C4244, you should either change your program to use compatible types, or add some logic to your code, to ensure that the range of possible values will always be compatible with the types you are using.
>An open brace occurs at global scope without a corresponding function header.This error can be caused by an old-style C++-language formal list.
>C3209....'class' : generic class must be a managed class A generic class must be a managed class.
>C2059 To determine the cause, examine not only the line listed in the error message, but also the lines above it. The following example generates an error message for the line declaring j, but the true source of the error appears on the line just above it.
If examining the lines yields no clue to what the problem might be, try commenting out the line listed in the error message and possibly several lines above it.
Try....to examine your braces.....you might forgot to close a function or a syntax
here are the errors 1. warning C4244: '=' : conversion from 'double' to 'float', possible loss of data 2. error C2447: '{' : missing function header (old-style formal list?) 3.: error C2059: syntax error : '}' 4 : error C2143: syntax error : missing ';' before '}' 5 : error C2059: syntax error : '}' 6: error C2447: '{' : missing function header (old-style formal list?) 7: error C2447: '{' : missing function header (old-style formal list?) 8 error C2447: '{' : missing function header (old-style formal list?) 9: error C3209: ' ' : Unicode identifiers are not yet supported 10: error C3209: ' ' : Unicode identifiers are not yet supported 11: error C3209: '(1' : Unicode identifiers are not yet supported
It is suppose to ask for the price, interest rate, down payment, trade in, and then give them monthly payment for 24 \, 36, 48, 60;mos
I have hit a brick wall any help is appriciated on getting this code worked out. Thanks!!!
Emily
The following appear to be the root cause: // get tile size in inches void getInterestRate( float& annualIntRate, float& annualIntPercent, float& monIntRate);<<--- something out of place here
Same function near the end: return; } }<<-- there are more closing than open braces
After I did a little more digging, you have the same ";" in the implementations of the functions....
Funny thing about errors, they often create more further down, confusing the issue for the programmer
count++; } cin.get(); // Wait for keypress before exiting. cin.get(); // Wait for keypress before exiting. return 0; }
// get price of vehicle void getPrice (int& price) { while ( price < 50000.00|| price > 0)
{ cout << "Enter the price of the Vehicle: "; cin >> price; if (price > 50000.00) cout << "Enter a price less than 50.\n"; if (price < 50.00) cout << "Enter a price less that 50000.\n"; } return; } // get interest rate void getInterestRate( float& annualIntRate, float& annualIntPercent, float& monIntRate)
{
while (annualIntRate >= 0 || annualIntRate > .50) { cout << "Enter the annual interest rate in decimals "; cin >> annualIntRate; if (annualIntRate < 0 || annualIntRate > .50) cout << "Enter a number less than .50 and greater than 0.\n"; } return; }
// getdownPayment: Prompts the user for the downPayment void getdownPayment(float& downPayment) {
bool dataInvalid = true; // Start with invalid data to begin the while loop
// Get our downPayment // while(dataInvalid) { cout << "enter the down payment "; cin >> downPayment; if (downPayment < 0) { cout << "------ Positive Values Only, reenter data. --------\n"; dataInvalid = true;
} dataInvalid = false;
} dataInvalid = true; // Start off invalid so the loop will execute // Get our down payment check for errors
while(dataInvalid);
// get trade in value void gettradeIn( float& tradeIn); { while (tradeIn >= 0) { cout << "Enter the value of the trade in "; cin >> tradeIn; if ( annualIntRate < 0) cout << "Enter a number greater than 0.\n"; } return; } // calculate the monthly payment for vehicle void calcmonPayment(float price, float downPayment, float tradeIn, float noMos, float monPayment, float loanAmt)
now here are my errors : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data : error C2065: 'tradeIn' : undeclared identifier : fatal error C1903: unable to recover from previous error(s); stopping compilation
Thanks in advance for any help correcting these, I am getting there thanks for all the help already offered
This post has been edited by eadams20: 23 Oct, 2006 - 06:09 AM
count++; } cin.get(); // Wait for keypress before exiting. cin.get(); // Wait for keypress before exiting. return 0; }
// get price of vehicle void getPrice (int& price) { while ( price < 50000.00|| price > 0)
{ cout << "Enter the price of the Vehicle: "; cin >> price; if (price > 50000.00) cout << "Enter a price less than 50.\n"; if (price < 50.00) cout << "Enter a price less that 50000.\n"; } return; } // get interest rate void getInterestRate( float& annualIntRate, float& annualIntPercent, float& monIntRate)
{
while (annualIntRate >= 0 || annualIntRate > .50) { cout << "Enter the annual interest rate in decimals "; cin >> annualIntRate; if (annualIntRate < 0 || annualIntRate > .50) cout << "Enter a number less than .50 and greater than 0.\n"; } return; }
// getdownPayment: Prompts the user for the downPayment void getdownPayment(float& downPayment) {
bool dataInvalid = true; // Start with invalid data to begin the while loop
// Get our downPayment // while(dataInvalid) { cout << "enter the down payment "; cin >> downPayment; if (downPayment < 0) { cout << "------ Positive Values Only, reenter data. --------\n"; dataInvalid = true;
} dataInvalid = false;
} dataInvalid = true; // Start off invalid so the loop will execute // Get our down payment check for errors
while(dataInvalid);
// get trade in value void gettradeIn( float& tradeIn) { while (tradeIn >= 0) { cout << "Enter the value of the trade in "; cin >> tradeIn; if ( annualIntRate < 0) cout << "Enter a number greater than 0.\n"; } return; } // calculate the monthly payment for vehicle void calcmonPayment(float price, float downPayment, float tradeIn, float noMos, float monPayment, float loanAmt) {
Compiling... midterm.cpp c:\Documents and Settings\Emily Adams\My Documents\Visual Studio Projects\midterm\midterm.cpp(116) : error C2601: 'gettradeIn' : local function definitions are illegal c:\Documents and Settings\Emily Adams\My Documents\Visual Studio Projects\midterm\midterm.cpp(129) : error C2601: 'calcmonPayment' : local function definitions are illegal c:\Documents and Settings\Emily Adams\My Documents\Visual Studio Projects\midterm\midterm.cpp(139) : error C3209: ' ' : Unicode identifiers are not yet supported c:\Documents and Settings\Emily Adams\My Documents\Visual Studio Projects\midterm\midterm.cpp(139) : error C3209: ' ' : Unicode identifiers are not yet supported
Build log was saved at "file://c:\Documents and Settings\Emily Adams\My Documents\Visual Studio Projects\midterm\Debug\BuildLog.htm" midterm - 4 error(s), 0 warning(s)
Without the closing brace, the compiler sees further function defintions as occurring inside that function. Count the opening and closing braces in the function specified, and you'll see what I mean.
In the same function while(dataInvalid); will run nothing...should it be there, or was it left over from something else? Same question for this: dataInvalid = true;. Finally, you're setting the bool variable dataInvalid to false no matter what the downpayment is, so the loop will execute only once. you may wish to put that in an else statement.