Welcome to Dream.In.Code
Become a C++ Expert!

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!




Errors during compilation

 
Reply to this topicStart new topic

Errors during compilation, Stuck on Loan code

eadams20
22 Oct, 2006 - 07:50 PM
Post #1

D.I.C Head
**

Joined: 30 Aug, 2006
Posts: 65


My Contributions
CODE


#include <cmath>
#include <iostream>

using namespace std;

//Function prototypes
    void getPrice (float&);
    void getInterestRate (float&, float&, float&);
    void getDownPayment ( float&);
    void gettradeIn (float&);
    void calcmonPayment (float, float, float, float, float, float&);

int main()
{
    
    
    
    // Input variables
    float price;
    float downPayment;
    float tradeIn;
    float loanAmt;
    float annualIntRate;
    float annualIntPercent;
    float monIntRate;
    float noMos;
    float monPayment;
    int count;
    // get price
    getPrice(price);

    // get interest rate
    getInterestRate (annualIntRate, annualIntPercent, monIntRate);

    while (count < price)
    {
        getDownPayment(downPayment);
        gettradeIn (tradeIn);
        calcmonPayment (price, downPayment, tradeIn, noMos, loanAmt, monPayment );
        cout << "\n\nprice of vehcile is" << monPayment << "per month\n\n";
            monPayment = annualIntRate  / 12.0;

       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);


    {

    
    // Convert feet to inches
    monIntRate =  (annualIntRate)  / 12.0;
   annualIntPercent = (annualIntRate) * 100.0;

   loanAmt = ((price) – (downPayment) – (tradeIn));

   monPayment = (loanAmt * monIntRate)/(1 –(1 + monIntRate) -pow(noMos);  
   noMos = 24, 36, 48, 60;


    
    return;
    
}



that is the code I have been working on.

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

edit: modified title ~ jayman9
User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Errors During Compilation
22 Oct, 2006 - 08:47 PM
Post #2

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
can you change the cmath to cmath.h

then we could proceed to your problem
User is offlineProfile CardPM
+Quote Post

eadams20
RE: Errors During Compilation
22 Oct, 2006 - 08:53 PM
Post #3

D.I.C Head
**

Joined: 30 Aug, 2006
Posts: 65


My Contributions
Okay i changed that

Emily

QUOTE(eadams20 @ 22 Oct, 2006 - 08:50 PM) *

CODE


#include <cmath>
#include <iostream>

using namespace std;

//Function prototypes
    void getPrice (float&);
    void getInterestRate (float&, float&, float&);
    void getDownPayment ( float&);
    void gettradeIn (float&);
    void calcmonPayment (float, float, float, float, float, float&);

int main()
{
    
    
    
    // Input variables
    float price;
    float downPayment;
    float tradeIn;
    float loanAmt;
    float annualIntRate;
    float annualIntPercent;
    float monIntRate;
    float noMos;
    float monPayment;
    int count;
    // get price
    getPrice(price);

    // get interest rate
    getInterestRate (annualIntRate, annualIntPercent, monIntRate);

    while (count < price)
    {
        getDownPayment(downPayment);
        gettradeIn (tradeIn);
        calcmonPayment (price, downPayment, tradeIn, noMos, loanAmt, monPayment );
        cout << "\n\nprice of vehcile is" << monPayment << "per month\n\n";
            monPayment = annualIntRate  / 12.0;

       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);


    {

    
    // Convert feet to inches
    monIntRate =  (annualIntRate)  / 12.0;
   annualIntPercent = (annualIntRate) * 100.0;

   loanAmt = ((price) – (downPayment) – (tradeIn));

   monPayment = (loanAmt * monIntRate)/(1 –(1 + monIntRate) -pow(noMos);  
   noMos = 24, 36, 48, 60;


    
    return;
    
}



that is the code I have been working on.

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

User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Errors During Compilation
22 Oct, 2006 - 09:12 PM
Post #4

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
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

then posed again....
User is offlineProfile CardPM
+Quote Post

eadams20
RE: Errors During Compilation
22 Oct, 2006 - 09:18 PM
Post #5

D.I.C Head
**

Joined: 30 Aug, 2006
Posts: 65


My Contributions
thanks alot I will look at those.


Emily

QUOTE(NyeNye @ 22 Oct, 2006 - 10:12 PM) *

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

then posed again....

User is offlineProfile CardPM
+Quote Post

NyeNye
RE: Errors During Compilation
22 Oct, 2006 - 09:28 PM
Post #6

D.I.C Head
**

Joined: 24 Sep, 2006
Posts: 248


My Contributions
Just posed your progress on this problem...

and i we will provide you...some help

if you want, you could browse the snippets on this site

it may help you alot.....
User is offlineProfile CardPM
+Quote Post

gregoryH
RE: Errors During Compilation
23 Oct, 2006 - 12:11 AM
Post #7

D.I.C Regular
Group Icon

Joined: 4 Oct, 2006
Posts: 417


Dream Kudos: 50
My Contributions
QUOTE(eadams20 @ 22 Oct, 2006 - 08:50 PM) *


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
User is offlineProfile CardPM
+Quote Post

eadams20
RE: Errors During Compilation
23 Oct, 2006 - 06:08 AM
Post #8

D.I.C Head
**

Joined: 30 Aug, 2006
Posts: 65


My Contributions
CODE

#include <cmath>
#include <iostream>

using namespace std;

//Function prototypes
    void getPrice (float&);
    void getInterestRate (float&, float&, float&);
    void getDownPayment ( float&);
    void gettradeIn (float&);
    void calcmonPayment (float, float, float, float, float, float&);

int main()
{
    
    
    
    // Input variables
    float price;
    float downPayment;
    float tradeIn;
    float loanAmt;
    float annualIntRate;
    float annualIntPercent;
    float monIntRate;
    float noMos;
    float monPayment;
    int count;
    // get price
    getPrice(price);

    // get interest rate
     getInterestRate (annualIntRate, annualIntPercent, monIntRate);

    while (count < price)
    {
        getDownPayment(downPayment);
        gettradeIn (tradeIn);
        calcmonPayment (price, downPayment, tradeIn, noMos, loanAmt, monPayment );
        cout << "\n\nprice of vehcile is" << monPayment << "per month\n\n";
            monPayment = annualIntRate  / 12.0;

       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)


    

    
    // fine monthly payment
    monIntRate =  (annualIntRate)  / 12.0;
   annualIntPercent = (annualIntRate) * 100.0;

   loanAmt = (price – downPayment – tradeIn);

   monPayment = ((loanAmt * monIntRate))/(1 –(1 + monIntRate)) -pow(noMos)));  
   noMos = 24, 36, 48, 60;


    
    return;
    
}


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
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Errors During Compilation
23 Oct, 2006 - 08:36 AM
Post #9

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
This function is never closed:
CODE

void getdownPayment(float& downPayment)

You are missing a closing brace.

This function is never opened:
CODE

void calcmonPayment(float price, float downPayment, float tradeIn,
                    float noMos, float monPayment, float loanAmt)

You are missing an opening brace.
User is offlineProfile CardPM
+Quote Post

eadams20
RE: Errors During Compilation
23 Oct, 2006 - 11:14 AM
Post #10

D.I.C Head
**

Joined: 30 Aug, 2006
Posts: 65


My Contributions
CODE

#include <cmath>
#include <iostream>

using namespace std;

//Function prototypes
    void getPrice (float&);
    void getInterestRate (float&, float&, float&);
    void getDownPayment ( float&);
    void gettradeIn (float&);
    void calcmonPayment (float, float, float, float, float, float&);

int main()
{
    
    
    
    // Input variables
    float price;
    float downPayment;
    float tradeIn;
    float loanAmt;
    float annualIntRate;
    float annualIntPercent;
    float monIntRate;
    float noMos;
    float monPayment;
    int count;
    // get price
    getPrice(price);

    // get interest rate
     getInterestRate (annualIntRate, annualIntPercent, monIntRate);

    while (count < price)
    {
        getDownPayment(downPayment);
        gettradeIn (tradeIn);
        calcmonPayment (price, downPayment, tradeIn, noMos, loanAmt, monPayment );
        cout << "\n\nprice of vehcile is" << monPayment << "per month\n\n";
            

       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)
{

    

    
    // fine monthly payment
    monPayment = annualIntRate  / 12.0;
    monIntRate =  (annualIntRate)  / 12.0;
    annualIntPercent = (annualIntRate) * 100.0;

    loanAmt = ((price) – (downPayment) – (tradeIn));

    monPayment = ((loanAmt * monIntRate))/((1 + monIntRate)) -pow(noMos)- 1));  
    noMos = 24, 36, 48, 60;

}
    
    return;
    
}


------ Build started: Project: midterm, Configuration: Debug Win32 ------

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)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Errors During Compilation
23 Oct, 2006 - 03:03 PM
Post #11

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
You have still not closed the following function:
CODE

void getdownPayment(float& downPayment)

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.

This function
CODE

void calcmonPayment(float price, float downPayment, float tradeIn,
                float noMos, float monPayment, float loanAmt)

has an extra brace.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:45AM
<