An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours and displays an employee’s total weekly pay.

Respuesta :

Answer:

C++ programming language is used to implement this program using Dev C++. You can use any C++ compiler to run this program. The code and its explanation is given below in explanation section.

Explanation:

#include<iostream>

using namespace std;

int main()

{

int totalWeeklyPay;//total weekly pay  

int hourlyWage;// wages per hours

 

int totalRegularHour;// total regular hours worked

int totalOverTimeHour;// total over time hours worked

 

int weeklyTotalRegularPay;

int weeklyTotalOverTimePay;

 

cout<<"Enter Wage per hour: ";

 cin>>hourlyWage;

 if (hourlyWage<0)//if use enter negative value

  {

   cout<<"Please enter positive number number for wage per hour\n";

   cout<<"Enter Wage per hour: ";

     cin>>hourlyWage;

  }

cout<<"Enter total regular hour: ";

cin>>totalRegularHour;

if (totalRegularHour<0)//if user enter negative value

  {

   cout<<"Please enter positive total number of regular hour\n";

  cout<<"Enter total regular hour: ";

     cin>>totalRegularHour;

  }

cout<<"Enter total over time hour: ";

cin>>totalOverTimeHour;

 

 if(totalOverTimeHour<0)//if user enter negative value

   {

    cout<<"Please enter positive total number of over time hour\n";

  cout<<"Enter total over time hour: ";

  cin>>totalOverTimeHour;

     

     

 }

 

weeklyTotalRegularPay =hourlyWage*totalRegularHour;// total weekly regular hour pay

weeklyTotalOverTimePay=totalOverTimeHour*hourlyWage*1.5;// total weekly overtime pay

totalWeeklyPay=weeklyTotalRegularPay + weeklyTotalOverTimePay;//total weekly regular hour pay + // total weekly overtime pay

cout<<"Total Weekly Pay is: "<<totalWeeklyPay<<"$";//output

 

 

return 0;

 

}