#include <iostream>
using namespace std;



//class definition
class Wage
{
public:

    int duration;
    int price;

    int calculateWage()
    {
        cout<<
        "To exit program enter -1, to continue enter 1! ";
        cin>> duration;

        while(duration != -1)
        {
            cout<<
            "\n\nEnter employee hours worked (or -1 to quit): ";
            cin>> duration;

            {
            if(duration <= 40 )
                {
                cout<<
                "\nEmployee regular working hours is: "<< duration << "hr.\n";
                cout<<
                "Employee Overtime hour(s) is: 0hr\n";
                cout<<
                "Employee net salary is: $" << duration*price << "\n\n\n";
                }
            else
                {
                cout<<
                "\nEmployee regular working hours is: 40hr.\n";
                cout<<
                "Employee Overtime hour(s) is: " <<duration-40 <<"hr.\n";
                cout<<
                "Employee net salary is: $" << ((40*price)+((duration-40)*(1.5*price))) <<"\n\n\n";

                }
            }

        }

    }


};

//executing actual program using function main

int main()
{

    Wage payRoll;
    payRoll.calculateWage();

return 0;
}

The price variable should be initialized to some value in your calculateWage function. Otherwise, your net salary calculations are meaningless.

This article has been dead for over six months. Start a new discussion instead.