error C2061 - Compile Error

This is a discussion on error C2061 - Compile Error within the C++ Programming forums, part of the General Programming Boards category; I am working on creating a program which calculates the amount a company will contribute towards an employees retiremnet plan ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    12

    error C2061 - Compile Error

    I am working on creating a program which calculates the amount a company will contribute towards an employees retiremnet plan based on the number of years the employee has worked
    for the company....I'm getting two errors at this point don't know where to go from here...here is the code.....the errors point to the two nested if/else if/else .... error C2061: syntax error : identifier 'Employee_Contribution' and 'Years_Worked....

    #include <iostream>
    using namespace std;

    int main()
    {
    std::cout << "\t\t*********** Retirement\t Calculator **********\n\n";

    //Initialize Variables//

    char Plan_Type;
    int Years_Worked, Salary, Company_Contribution, Employee_Contribution;

    //Prompt for user input//

    cout << "Enter plan type (S = Standard Plan M = Match Plan). --->\n";
    cin >> Plan_Type;

    if (Plan_Type == 's' || Plan_Type == 'S')
    {
    if Years_Worked >= 5 Company_Contribution = 10
    else if Years_Worked >= 2 && Years_Worked < 5 Company_Contribution = 5
    else Company_Contribution = 0
    }

    else if (Plan_Type == 'm' || Plan_Type == 'M')
    {
    if Employee_Contribution >= 6 Company_Contribution = 6
    else if Employee_Contribution < 6 Company_Contribution = Employee_Contribution
    else Employee_Contribution < 0 Company_Contribution = 0
    }

    else cout << "INVALID PLAN LETTER\n";

    cout << "How many years has the employee worked for this company? --->\n";
    cin >> Years_Worked;


    cout << "What percentage did the employee contribute? --->\n";
    cin >> Employee_Contribution;

    cout << "What was the employees last years salary? --->\n";
    cin >> Salary;

    //Calculation//

    if (Plan_Type == 's' || 'S')
    Company_Contribution = Salary/Company_Contribution;
    else (Plan_Type == 'm' || 'M');
    Company_Contribution = Salary/Employee_Contribution;

    //Output//

    cout << "The total contribution made to the employee byt the company was <<Company_Contribution<<.\n";


    return 0;
    }

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    i notice that you are new here... it's a good idea to post your code between [ code ] [ /code ] tags (without the spaces) so that they retain their formatting.. more people will read your code if you do.

    make sure that all of your conditions are in parenthesis ()
    and make sure that every line of code is terminated with a ';'

    for example:

    if Years_Worked >= 5 Company_Contribution = 10

    should be

    if(Years_Worked >= 5)Company_Contribution = 10;

    it's a good idea to put your code in a block... like this:

    Code:
    if(Years_Worked >= 5)
    {
          Company_Contribution = 10;
    }
    good luck!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21