[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

Needs help in calculation

Hi guys: I am trying to calculate the gross pay for salaried and hourly employees and calculate and display the gross pay of three salaried employes as well as calculate and display the gross pay of two hourly employees but getting errors needs help. Thanks.


#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
class GrossPay
{
      public clacGross(double);
      double calcGross(double, double);
};

double GrossPay::calcGross(double yearSalary)
{
       return yearSalary / 24;
}

double GrossPay::calcGross(double h, double r)
{
       return h * r;
}

int main()
{
    GrossPay employGross;
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
          else
             {
               cout << "Incorrect employee type." << endl;
          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x = 1; x < 4; x += 1)
      {
       

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int x = 1; x < 3; x += 1)
      {

      }

      system("pause");
      return 0;
}
0
mustish1
Asked:
mustish1
  • 12
  • 10
  • 2
  • +1
1 Solution
 
mustish1Author Commented:
C:\Documents and Settings\Kathy\My Documents\test.cpp:9: error: candidate is: double GrossPay::calcGross(double, double)

C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:69: error: expected `}' at end of input

Execution termina
0
 
käµfm³d 👽Commented:
It looks like you're missing a closing brace ( } ) on your "else" condition.
0
 
gyettonCommented:
you declare one constructor as public and one as double...
   public clacGross(double);
   double calcGross(double, double);

shouldn't they both be public double calcGross(...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mustish1Author Commented:
C:\Documents and Settings\Kathy\My Documents\test.cpp:10: error: candidate is: double GrossPay::calcGross(double, double)

C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:70: error: expected `}' at end of input

Execution terminated


#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
class GrossPay
{
      public:
      double clacGross(double);
      double calcGross(double, double);
};

double GrossPay::calcGross(double yearSalary)
{
       return yearSalary / 24;
}

double GrossPay::calcGross(double h, double r)
{
       return h * r;
}

int main()
{
    GrossPay employGross;
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
          else
             {
               cout << "Incorrect employee type." << endl;
          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x = 1; x < 4; x += 1)
      {
       

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int x = 1; x < 3; x += 1)
      {

      }

      system("pause");
      return 0;
}
0
 
Raheman M. AbdulCommented:
#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{

      public  double calcGross(double yearSalary);
      public  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
          else
             {
               cout << "Incorrect employee type." << endl;
          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
käµfm³d 👽Commented:
Um...   OK?
0
 
mustish1Author Commented:
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Kathy\My Documents\test.cpp" -o "C:\Documents and Settings\Kathy\My Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected unqualified-id before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected `,' or `;' before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:13: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp:18: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: `GrossPay' undeclared (first use this function)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: expected `;' before "employGross"

C:\Documents and Settings\Kathy\My Documents\test.cpp:39: error: `employGross' undeclared (first use this function)

C:\Documents and Settings\Kathy\My Documents\test.cpp:70: error: expected `}' at end of input

Execution terminated
#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{

      public  double calcGross(double yearSalary);
      public  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
          else
             {
               cout << "Incorrect employee type." << endl;
          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}




0
 
Raheman M. AbdulCommented:

#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{

      public  double calcGross(double yearSalary);
      public  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
mustish1Author Commented:
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Kathy\My Documents\test.cpp" -o "C:\Documents and Settings\Kathy\My Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected unqualified-id before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected `,' or `;' before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:13: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp:18: error: `GrossPay' has not been declared
C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: `GrossPay' undeclared (first use this function)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: expected `;' before "employGross"

C:\Documents and Settings\Kathy\My Documents\test.cpp:39: error: `employGross' undeclared (first use this function)

Execution terminated

#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{

      public  double calcGross(double yearSalary);
      public  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}

0
 
Raheman M. AbdulCommented:
sorry you should change the first two lines
#include<iostream.h>
#include<iomanip.h>
0
 
Raheman M. AbdulCommented:
change the class declaration to:
public class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};
0
 
mustish1Author Commented:
Thanks. it runs but it just print
Salaried gross pay
Hourly gross pay
Press any key to continue.....
0
 
mustish1Author Commented:
it display the same message.


#include<iostream.h>
#include<iomanip.h>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" << endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" << endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
Raheman M. AbdulCommented:
#include<iostream.h>
#include<iomanip.h>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" <<gross<<endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" <<gross<<endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
Raheman M. AbdulCommented:
We did not write gross in the cout statement so its was not printing any output (here: value of gross)
0
 
mustish1Author Commented:


Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Kathy\My Documents\test.cpp" -o "C:\Documents and Settings\Kathy\My Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
                 from C:\Documents and Settings\Kathy\My Documents\test.cpp:1:
C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected unqualified-id before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected `,' or `;' before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:13: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp:18: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: `GrossPay' undeclared (first use this function)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: expected `;' before "employGross"

C:\Documents and Settings\Kathy\My Documents\test.cpp:39: error: `employGross' undeclared (first use this function)

Execution terminated



#include<iostream.h>
#include<iomanip.h>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" <<gross<<endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" <<gross<<endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
mustish1Author Commented:
i get warnings on header files.
0
 
Raheman M. AbdulCommented:
C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

From the above error, i guess try <iostream> and compile again

try -Wno-deprecated   in the compile command
0
 
mustish1Author Commented:
Now it giving me error on that
public class GrossPay
Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\Kathy\My Documents\test.cpp" -o "C:\Documents and Settings\Kathy\My Documents\test.exe"    -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include"  -I"C:\Dev-Cpp\include\c++\3.4.2\backward"  -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32"  -I"C:\Dev-Cpp\include\c++\3.4.2"  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected unqualified-id before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:6: error: expected `,' or `;' before "public"
C:\Documents and Settings\Kathy\My Documents\test.cpp:13: error: `GrossPay' has not been declared
C:\Documents and Settings\Kathy\My Documents\test.cpp:18: error: `GrossPay' has not been declared

C:\Documents and Settings\Kathy\My Documents\test.cpp: In function `int main()':
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: `GrossPay' undeclared (first use this function)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: (Each undeclared identifier is reported only once for each function it appears in.)
C:\Documents and Settings\Kathy\My Documents\test.cpp:25: error: expected `;' before "employGross"

C:\Documents and Settings\Kathy\My Documents\test.cpp:39: error: `employGross' undeclared (first use this function)

Execution terminated


I am using DEV-C++ IDE How to i change that option?
--------------------------------

#include <iostream>
#include <iomanip>
//Displays the gross pay for salaried
//and hourly employees
using namespace test;
public class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

int main()
{
    GrossPay employGross=new GrossPay();
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" <<gross<<endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" <<gross<<endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}

IDE.JPG
0
 
Raheman M. AbdulCommented:
try removing the line
using namespace test;


Alternatively, make a simple C++ program  with a simple class and test
0
 
mustish1Author Commented:
ok. What i did i separate the files now it working. If experts please last thing  tell me how to i put the input into the loop so that the program will display the gross pay of three salaried employes as well as calculate and display the gross pay of two hourly employees  Thanks.

class GrossPay
{
      public:
                  double calcGross(double yearSalary);
                  double calcGross(double h, double r);
};

double GrossPay::calcGross(double yearSalary)
{
       return (yearSalary/24);
}

double GrossPay::calcGross(double h, double r)
{
       return (h*r);
}

-------------------------------------
#include<iostream>
#include<iomanip>
#include "GrossPay.h"
using namespace test;
int main()
{
//    GrossPay employGross=new GrossPay();
    GrossPay employGross;
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross      = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         cout << "Annual salary:";
         cin >> salary;
         gross = employGross.calcGross(salary);
       }
     else if(employType == 2)
           {
            cout << "Hours worked:";
            cin >> hours;
            cout << "Hourly pay:";
            cin >> hrlyPay;
            gross = employGross.calcGross(hours, hrlyPay);
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }

          cout << fixed << setprecision(2);
            cout << "Salaried gross pay" <<gross<<endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

      cout << endl << "Hourly gross pay" <<gross<<endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
Raheman M. AbdulCommented:
do you want the program to ask for inputs from 3 salaries employes and 2 hourly employees?
u mean it should ask for 5 times ?
0
 
mustish1Author Commented:
Yes and then display the output of all 5.

Thanks.
0
 
Raheman M. AbdulCommented:
#include<iostream>
#include<iomanip>
#include "GrossPay.h"
using namespace test;
int main()
{
//    GrossPay employGross=new GrossPay();
    GrossPay employGross;
    int employType    = 0;
    double salary     = 0.0;
    double hrlyPay    = 0.0;
    double gross     = 0.0;
      double yearSalary = 0.0;
      double hours      = 0.0;
      double payRate    = 0.0;
int salaried=3,hourly=2;
int count=0;
while(count<5)
{
    cout << "Salaried 1 or Hourly 2";
    cin >> employType;
    if(employType == 1)
      {
         if(salaried--)
         {
             cout << "Annual salary:";
             cin >> salary;
             gross = employGross.calcGross(salary);
              cout << fixed << setprecision(2);
            cout << endl<<"Salaried gross pay" <<gross<<endl;
         }
       }
     else if(employType == 2)
           {
              if(hourly--)
                {
                   cout << "Hours worked:";
                   cin >> hours;
                    cout << "Hourly pay:";
                    cin >> hrlyPay;
                    gross = employGross.calcGross(hours, hrlyPay);
                    cout << endl << "Hourly gross pay" <<gross<<endl;
                 }
            }
else
             {
               cout << "Incorrect employee type." << endl;
               system("pause");
               return (1);  // return error code
              }
} // end while loop

//            cout << fixed << setprecision(2);
//            cout << "Salaried gross pay" <<gross<<endl;
      for (int x=1; x<4; x++)
      {
        ;

      }      //end for

//      cout << endl << "Hourly gross pay" <<gross<<endl;
      //calculate and display the gross pay
      //for two hourly employees
      for (int y=1; y<3; y++)
      {
           ;
      }

      system("pause");
      return 0;
}
0
 
mustish1Author Commented:
Thanks a lot.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 12
  • 10
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now