#include <iostream>
    #include <fstream>
    #include <string>
    #include <cmath>
    #include <cassert>

    using namespace std;

    class Payroll
    {

    public:
    int menu();
    int option;
    int mainMenuOption();
    int payrollMenu();
    int employeeMenu();
    int employeeOption;
    int payrollOption();
    int anotherOption();
    int exitOption();
    int mainMenuOption;
    {
    system("cls");

    cout << "\t\t Docket Materials Company\n\n";
    cout << "\t\t Main M E N U option\n\n";
    cout << "\t\t[1.]Calculate Employee Salary\n\n";
    cout << "\t\t[2.]Print Employee Payroll Information\n\n";
    cout << "\t\t[3.]Calculate Another Employee\n\n";
    cout << "\t\t[4.]Exit\n\n";
    cout << "Please Enter Menu Option: 1, 2, 3, or 4";
    cin >> mainMenuOption;
    return mainMenuOption;
    }

    void employeeSalary()
    {
    system("cls");
    string name,dummy;

    //Declare Variables
    double code;
    double positionPay = 0;
    double hours = 0;
    double ot = 0;
    double grossPay = 0;
    double statusPay = 0;
    double bonus = 0;
    double tax = 0;
    double medicare = 0;
    double socialsecurity = 0;
    double pay = 0;
    double totalDeductions = 0;
    double netPay = 0;


    //Count the Employees
    cout.setf(ios::fixed,ios::floatfield);
    cout.precision(2);

    //Set Decimal Precision
    cout << "Please enter an Employee Number (between 100 and 200 inclusively): ";
    cin >> code;
    while (code < 100 ||code > 201)
    {
    cout<<"Invalid Employee Number!"<<endl;
    system("pause");
    system("cls");
    cout << "Please enter an Employee Number(between 100 and 200 inclusively): ";
    cin >> code;
    }
    getline(cin, dummy);
    cout << "Please enter the Employee's Name: Example: Last Name, First Name: ";
    getline(cin, name);


    // Prompt the user to enter Employee's Position
    cout << "Please enter the Employee's Position:\n"
    << "M = Manager, S = Supervisor, E = Employee: ";
    int position;
    cin >> position;
    position = toupper(position);

    // Compute Position Pay
    double positionPay = 0;

    if (position == M)
    {

    positionPay = 40.00;

    }
    else if (position == S)
    {
    positionPay = 20.00;

    }
    else if (status == E)
    {

    positionPay = 10.00;

    }
    else
    {
    cout << "Error: invalid status";
    return 0;
    }

    //Prompt the user to enter the Employee's hours.
    cout << "Please Enter the Number of Hours the Employee Worked: ";
    cin >> hours;

    while(hours < 1)
    {
    cout << "The Employee must have worked a minimum of 1 hour to process payroll" << hours << endl;
    cin >> hours;
    }
    // Determine the Overtime


    // Convert the Hours Worked to Gross Pay Amount
    if(hours>=40)
    {
    ot = hours - 40;
    hours = 40;
    }

    grosspay = (ot * 1.5 * positionPay) + (hours * positionPay);


    // Prompt the user to enter Insurance Status
    cout << "Please Enter the Employee's Insurance Type or Status\n"
    << "1 = Single Filer, 2 = Single With Children Filer,\n"
    << "3 = Married Filer, 4 = Married With Children Filer: ";
    int status;
    cin >> status;
    ststus = toupper(status);


    // Compute Insurance Deductions
    double statusPay = 0;

    if (status == 1)
    {
    // Compute Insurance Deductions
    for Single Filer

    statusPay = grossPay * 0.02;

    }
    else if (status == 2)
    {
    // Compute Insurance Deductions for Single Filer with Children

    statusPay = grossPay * 0.03;

    }
    else if (status == 3)
    {
    // Compute Insurance Deductions for Married Filer

    statusPay = grossPay * 0.04;

    }

    else if (status == 4)
    {

    // Compute Insurance Deductions for Married Filer with Children

    statusPay = grossPay * 0.05;

    }
    else
    {
    cout << "Error: invalid status";
    return 0;


    //Calculate Bonus Pay
    {
    if(grossPay >= 5000.00)
    bonus = 1000.00;
    else if(grossPay <= 4999.00)
    bonus = 600.00;
    else (grossPay < 3000.00)
    bonus = 0.00;
    }
    // Compute Tax
    double tax = 0;
    {
    // Compute tax if Gross Pay is Greater than or Equal to 7000.00

    if (grossPay >= 7000.00)
    tax = grossPay * 0.15;
    else if (grossPay <= 6999.00)
    tax = grossPay * 0.10;
    else if (income <= 3999)
    tax = grossPay * 0.05;
    else if (income < 2000.00)
    tax = grossPay * 0.00;
    else
    tax = 0.00;
    }

    //Medicare Deductions
    double medicare = 100.00;

    //Social Security Tax
    double socialSecurity = 0;

    socialSecurity = grossPay * 0.05;

    //Compute Taxes
    pay = grossPay + bonus;
    totalDeductions = tax + socialSecurity + medicare + insurance;
    netPay = grossPay + bonus - totalDeductions;

    return employeeSalary;
    }
    //--------------------------------------------------------------------------------------
    void printReportOption()
    {
    // Display the Payroll Information for the Employee
    cout << "Pay information for Employee: " << code << endl;
    cout << "Employee Position: " << position << endl;
    cout << "The hours worked for the period are: " << hours << endl;
    cout << "Regular Pay: " << fixed << setprecision(2) << "$" << grossPay << "Pay Rate: " << positionPay << endl;
    cout << "Bonus Pay: " << fixed << setprecision(2) << "$" << bonus << endl;
    cout << "\n";
    cout << "Pay (including Bonus): " << fixed << setprecision(2) << "$" << pay << "\tInsurance Type: " << status << endl;
    cout << "\n";
    cout << "==============================" << endl;
    cout << right;
    cout << setw(25) << setprecision(2) << "Tax Deduction " << setw(10) << setprecision(2) << "$" << tax << endl;
    cout << setw(25) << setprecision(2) << "Insurance Deduction: " << setw(10) << setprecision(2) << "$" << insurance << endl;
    cout << setw(25) << setprecision(2) << "Social Security: " << setw(10) << setprecision(2) << "$" << socialSecurity << endl;
    cout << setw(25) << setprecision(2) << "Medicare: " << setw(10) << setprecision(2) << "$" << Medicare << endl;
    cout << "==============================" << endl;
    cout << "\n"
    cout << "Total Deductions: " << setw(10) << setprecision(2) << "$" << totalDeductions << endl;
    cout << "Net Pay: " << setw(10) << setprecision(2) << "$" << netPay << endl;
    cout << "\n"
    return printReportOption;
    }
    //-----------------------------------------------------------------------------------------
    void anotherOption()
    {

    cout << "\nDo you want to enter another employee? (Y = Yes, N = No)" << endl;
    cin >> another;
    another = toupper(another);

    }
    //-----------------------------------------------------------------------------------------
    void displayMenu()
    {

    cout << "\t\t Docket Materials Company\n\n";
    cout << "\t\t Main M E N U option\n\n";
    cout << "\t\t[1.]Calculate Employee Salary\n\n";
    cout << "\t\t[2.]Print Employee Payroll Information\n\n";
    cout << "\t\t[3.]Calculate Another Employee\n\n";
    cout << "\t\t[4.]Exit\n\n";

    cout << "Please Enter Menu Option: 1, 2, 3, or 4";


    }
    //-----------------------------------------------------------------------------------------
    int displaySelection(int opt)
    {
    int menu;
    if (opt == 1)
    menu = employeeSalary();
    menu = 1;
    else if (opt == 2)
    menu = printReportOption();
    menu = 2;
    else if (opt == 3)
    menu = anotherOption()
    menu = 3;
    else if (opt == 4)
    menu = exitOption;
    menu = 4;
    return displayMenu;
    //end ifs

    }

    int main()
    {

    int menu;
    int choice;
    displayMenu();
    cout << "Enter Main Menu Option:";
    cin >> choice;
    system("cls");

    while (choice !=1 && choice != 2 && choice != 3 && choice)
    {
    cout<<"Invalid Option Nubmber";
    displayMenu();
    cout << "Enter menu option:";
    cin >> choice;
    system("cls");
    }
    menu = displaySelection(choice);
    if (menu == 1)
    {
    employeeSalary();
    menu = mainMenuOption();
    }
    else if (menu == 2)
    {
    printReportOption();
    menu = mainMenuOption();
    }
    else if (menu == 3)
    {
    anotherOption();
    menu = mainMenuOption();
    }
    else if (menu == 4)
    {
    exitOption()
    menu = mainMenuOption();
    }
    else
    return displayMenu;


    display();

   system("CLS");   // Clean Console
        return 0;

}

I should of said in the first post.... You can tell it yet another payroll program. Also these are the errors I get ..... (and I just can't find fix error 3 for the life of me!)

Error 2 error C2365: 'Payroll::mainMenuOption' : redefinition; previous definition was 'member function' (LINE 22)

Error 3 error C2059: syntax error : '{' (LINE 23)

Error 4 error C2334: unexpected token(s) preceding '{'; skipping apparent function body (LINE 23)

Error 5 fatal error C1075: end of file found before the left brace '{' at 'c:\users\justin\desktop\83618-4\cpp5\chap13\ch13appe02 solution\ch13appe02 project\ch13appe02.cpp(38)' was matched c:\users\justin\desktop\83618-4\cpp5\chap13\ch13appe02 solution\ch13appe02 project\ch13appe02.cpp (LINE 343)

Meh.
+1 for managing to use code tags on the first post - that was promising...
-1 for posting code lacking any indentation at all.
-20 for just dumping a sorry mess of code and not saying a damn word about it.

What's wrong with it?
What does it do?
What is it supposed to do?

I suppose the only bright spot is that it's Friday. The usual form is midnight (or 30 minutes).

Meh.
+1 for managing to use code tags on the first post - that was promising...
-1 for posting code lacking any indentation at all.
-20 for just dumping a sorry mess of code and not saying a damn word about it.

What's wrong with it?
What does it do?
What is it supposed to do?

I suppose the only bright spot is that it's Friday. The usual form is midnight (or 30 minutes).

That's funny. I realized all of that after I posted it and was typing it up as you were typing yours, i guess. Any suggestions? Thanks!

I think if I can fix that semicolon in line 22 or around there. It will fix the other errors. Only problem is I've been looking for the past 3 hours on what is wrong.

You have a kind of hybrid declaration/definition there on 22 which is incorrect. Change it to look like a method definition without the ; and with (). Of course add any parameters to the method that you need.

Ok... So I finally got the program to run. But when I enter the empolyee number and then the employee position (M,S, or E). It just says... "The Employee must have worked a minimum of 1 hour to process payroll" over and over.

#include <iostream>
    #include <fstream>
    #include <string>
    #include <cmath>
    #include <cassert>

    using namespace std;

	

    //Declare Variables
    double code;
    double positionPay = 0;
    double hours = 0;
    double ot = 0;
    double grossPay = 0;
    double statusPay = 0;
    double bonus = 0;
    double tax = 0;
    double medicare = 0;
	int insurance = 0;
    double socialSecurity = 0;
    double pay = 0;
    double totalDeductions = 0;
    double netPay = 0;
	double employeeSalary = 0;
	int name;

	int main()
	{

    //Set Decimal Precision
    cout << "Please enter an Employee Number (between 100 and 200 inclusively): ";
    cin >> code;
    while (code < 100 ||code > 201)
    {
    cout << "Invalid Employee Number!"<<endl;
    
    cout << "Please enter an Employee Number(between 100 and 200 inclusively): ";
    cin >> code;
    }
    
   


    // Prompt the user to enter Employee's Position
    cout << "Please enter the Employee's Position: M = Manager, S = Supervisor, E = Employee: ";
    int position;
    cin >> position;
    position = toupper(position);

    // Compute Position Pay
    double positionPay = 0;

    if (position == 'M')
    {

    positionPay = 40.00;

    }
    else if (position == 'S')
    {
    positionPay = 20.00;

    }
    else if (position == 'E')
    {

    positionPay = 10.00;

    }
    else
    {
    cout << "Error: invalid status";
    
    }
	{
    //Prompt the user to enter the Employee's hours.
    cout << "Please Enter the Number of Hours the Employee Worked: ";
    cin >> hours;
	}
    while(hours < 1)
    {
    cout << "The Employee must have worked a minimum of 1 hour to process payroll" << hours << endl;
    cin >> hours;
    }
    // Determine the Overtime


    // Convert the Hours Worked to Gross Pay Amount
    if(hours>=40)
    {
    ot = hours - 40;
    hours = 40;
    }

    grossPay = (ot * 1.5 * positionPay) + (hours * positionPay);


    // Prompt the user to enter Insurance Status
    cout << "Please Enter the Employee's Insurance Type or Status\n"
    << "1 = Single Filer, 2 = Single With Children Filer,\n"
    << "3 = Married Filer, 4 = Married With Children Filer: ";
    int status;
    cin >> status;
    status = toupper(status);


    // Compute Insurance Deductions
    double statusPay = 0;

    if (status == 1)
    {
    // Compute Insurance Deductions
    

    statusPay = grossPay * 0.02;

    }
    else if (status == 2)
    {
    // Compute Insurance Deductions for Single Filer with Children

    statusPay = grossPay * 0.03;

    }
    else if (status == 3)
    {
    // Compute Insurance Deductions for Married Filer

    statusPay = grossPay * 0.04;

    }

    else if (status == 4)
    {

    // Compute Insurance Deductions for Married Filer with Children

    statusPay = grossPay * 0.05;

    }
    else
    {
    cout << "Error: invalid status";
    return 0;


    //Calculate Bonus Pay
    {
    if(grossPay >= 5000.00)
    bonus = 1000.00;
    else if(grossPay <= 4999.00)
    bonus = 600.00;
    else (grossPay < 3000.00);
    bonus = 0.00;
    }
    // Compute Tax
    double tax = 0;
    {
    // Compute tax if Gross Pay is Greater than or Equal to 7000.00

    if (grossPay >= 7000.00)
    tax = grossPay * 0.15;
    else if (grossPay <= 6999.00)
    tax = grossPay * 0.10;
    else if (grossPay <= 3999)
    tax = grossPay * 0.05;
    else if (grossPay < 2000.00)
    tax = grossPay * 0.00;
    else
    tax = 0.00;
    }

    //Medicare Deductions
    double medicare = 100.00;

    //Social Security Tax
    double socialSecurity = 0;

    socialSecurity = grossPay * 0.05;

    //Compute Taxes
    pay = grossPay + bonus;
    totalDeductions = tax + socialSecurity + medicare + insurance;
    netPay = grossPay + bonus - totalDeductions;

    return employeeSalary;
    
	}
    //--------------------------------------------------------------------------------------
   
    {
    // Display the Payroll Information for the Employee
    cout << "Pay information for Employee: " << code << endl;
    cout << "Employee Position: " << position << endl;
    cout << "The hours worked for the period are: " << hours << endl;
    cout << "Regular Pay: " << fixed << "$" << grossPay << "Pay Rate: " << positionPay << endl;
    cout << "Bonus Pay: " << fixed << "$" << bonus << endl;
    cout << "\n";
    cout << "Pay (including Bonus): " << fixed << "$" << pay << "\tInsurance Type: " << status << endl;
    cout << "\n";
    cout << "==============================" << endl;
    cout << right;
    cout << "Tax Deduction " << "$" << tax << endl;
    cout << "Insurance Deduction: "  << "$" << insurance << endl;
    cout << "Social Security: "  << "$" << socialSecurity << endl;
    cout << "Medicare: " << "$" << medicare << endl;
    cout << "==============================" << endl;
    cout << "\n";
    cout << "Total Deductions: " << "$" << totalDeductions << endl;
    cout << "Net Pay: " << "$" << netPay << endl;
    cout << "\n";
   
    }
    //-----------------------------------------------------------------------------------------
return 0;	
}

After the input on Line 49 there is still a newline character ('\n') that is lingering in the input stream. When you get to the next input (on Line 80), an invalid input type is detected which causes your input stream to get corrupted. You need to extract this before any other input. Add cin.ignore() between Lines 49 and 50 to do the required extraction.

You see, this is why crappy indentation will screw you over EVERY TIME.

Here, your code indented, so it actually follows what you wrote:

#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cassert>

using namespace std;

//Declare Variables
double code;
double positionPay = 0;
double hours = 0;
double ot = 0;
double grossPay = 0;
double statusPay = 0;
double bonus = 0;
double tax = 0;
double medicare = 0;
int insurance = 0;
double socialSecurity = 0;
double pay = 0;
double totalDeductions = 0;
double netPay = 0;
double employeeSalary = 0;
int name;

int main()
{
  //Set Decimal Precision
  cout << "Please enter an Employee Number (between 100 and 200 inclusively): ";
  cin >> code;
  while (code < 100 ||code > 201)
  {
    cout << "Invalid Employee Number!"<<endl;
    cout << "Please enter an Employee Number(between 100 and 200 inclusively): ";
    cin >> code;
  }

  // Prompt the user to enter Employee's Position
  cout << "Please enter the Employee's Position: M = Manager, S = Supervisor, E = Employee: ";
  int position;
  cin >> position;
  position = toupper(position);

  // Compute Position Pay
  double positionPay = 0;

  if (position == 'M')
  {
    positionPay = 40.00;
  }
  else if (position == 'S')
  {
    positionPay = 20.00;
  }
  else if (position == 'E')
  {
    positionPay = 10.00;
  }
  else
  {
    cout << "Error: invalid status";
  }


  {
    //Prompt the user to enter the Employee's hours.
    cout << "Please Enter the Number of Hours the Employee Worked: ";
    cin >> hours;
  }
  while(hours < 1)
  {
    cout << "The Employee must have worked a minimum of 1 hour to process payroll" << hours << endl;
    cin >> hours;
  }
  // Determine the Overtime

  // Convert the Hours Worked to Gross Pay Amount
  if(hours>=40)
  {
    ot = hours - 40;
    hours = 40;
  }

  grossPay = (ot * 1.5 * positionPay) + (hours * positionPay);

  // Prompt the user to enter Insurance Status
  cout << "Please Enter the Employee's Insurance Type or Status\n"
       << "1 = Single Filer, 2 = Single With Children Filer,\n"
       << "3 = Married Filer, 4 = Married With Children Filer: ";
  int status;
  cin >> status;
  status = toupper(status);

  // Compute Insurance Deductions
  double statusPay = 0;

  if (status == 1)
  {
    // Compute Insurance Deductions
    statusPay = grossPay * 0.02;
  }
  else if (status == 2)
  {
    // Compute Insurance Deductions for Single Filer with Children
    statusPay = grossPay * 0.03;
  }
  else if (status == 3)
  {
    // Compute Insurance Deductions for Married Filer
    statusPay = grossPay * 0.04;
  }
  else if (status == 4)
  {
    // Compute Insurance Deductions for Married Filer with Children
    statusPay = grossPay * 0.05;
  }
  else
  {
    cout << "Error: invalid status";
    return 0;

    //Calculate Bonus Pay
    {
      if(grossPay >= 5000.00)
        bonus = 1000.00;
      else if(grossPay <= 4999.00)
        bonus = 600.00;
      else (grossPay < 3000.00);  //!! this isn't even valid syntax
        bonus = 0.00;
    }

    // Compute Tax
    double tax = 0;
    {
      // Compute tax if Gross Pay is Greater than or Equal to 7000.00

      if (grossPay >= 7000.00)
        tax = grossPay * 0.15;
      else if (grossPay <= 6999.00)
        tax = grossPay * 0.10;
      else if (grossPay <= 3999)
        tax = grossPay * 0.05;
      else if (grossPay < 2000.00)
        tax = grossPay * 0.00;
      else
        tax = 0.00;
    }

    //Medicare Deductions
    double medicare = 100.00;

    //Social Security Tax
    double socialSecurity = 0;

    socialSecurity = grossPay * 0.05;

    //Compute Taxes
    pay = grossPay + bonus;
    totalDeductions = tax + socialSecurity + medicare + insurance;
    netPay = grossPay + bonus - totalDeductions;

    return employeeSalary;
  }
  //--------------------------------------------------------------------------------------

  {
    // Display the Payroll Information for the Employee
    cout << "Pay information for Employee: " << code << endl;
    cout << "Employee Position: " << position << endl;
    cout << "The hours worked for the period are: " << hours << endl;
    cout << "Regular Pay: " << fixed << "$" << grossPay << "Pay Rate: " << positionPay << endl;
    cout << "Bonus Pay: " << fixed << "$" << bonus << endl;
    cout << "\n";
    cout << "Pay (including Bonus): " << fixed << "$" << pay << "\tInsurance Type: " << status << endl;
    cout << "\n";
    cout << "==============================" << endl;
    cout << right;
    cout << "Tax Deduction " << "$" << tax << endl;
    cout << "Insurance Deduction: "  << "$" << insurance << endl;
    cout << "Social Security: "  << "$" << socialSecurity << endl;
    cout << "Medicare: " << "$" << medicare << endl;
    cout << "==============================" << endl;
    cout << "\n";
    cout << "Total Deductions: " << "$" << totalDeductions << endl;
    cout << "Net Pay: " << "$" << netPay << endl;
    cout << "\n";
  }

  //-----------------------------------------------------------------------------------------
  return 0;
}

There's a whole block of code starting at line 123 which is NEVER executed. The return statement on line 121 sees to that.

Further, it only stood a chance of executing if you got as far as the error message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.