Sunday 5 August 2012

How to calculate weekly pay of employees in C++



Program to calculate weekly pay as payment for Employees



#include<iostream>

#include<conio.h>

using namespace std;

int main()
{
       int regular_hours = 0, total_overtime = 0;
      
       double hourly_wage = 0.00, payment_made = 0.00;

       cout << "\n\n\t\t    __ Employees Weekly Pay Wages __";

       cout << "\n\n\n Regular Hours Worked (in hours)    ->  ";

       cin >> regular_hours;

       cout << "\n\n Overtime Hours Worked (int hours)  ->  ";

       cin >> total_overtime;

       cout << "\n\n Hourly Wage Rate (in $)            ->  ";

       cin >> hourly_wage;

       payment_made = (hourly_wage * regular_hours) + ( hourly_wage * total_overtime * 1.5);
      
      cout << "\n\n\n\t  Weekly Pay ( " << hourly_wage << " * " <<  regular_hours << " ) + ";
      
       cout << "( " << hourly_wage << " * " <<  total_overtime << " * 1.5 )" <<  " =  $ " << payment_made;

       getch();
             
       return 0;
}


Program reads the values from an employee’s time sheet, and calculate and print the weekly pay owing to that employee.
The values read in are the total number of regular hours worked the total overtime hours and the hourly wage rate. Weekly pay is calculated as payment for regular hours worked, plus payment for overtime hours worked. 
Payment for regular hours worked is calculated as (wage rate times regular hours worked); payment for overtime hours worked is calculated as (wage rate times overtime hours worked times 1.5).

No comments:

Post a Comment