Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ 1. Program: Create a C++ program that will function as an Employee Salary Ca

ID: 3914356 • Letter: C

Question

C++

1. Program: Create a C++ program that will function as an Employee Salary Calculator. Obtain from the user:
a. Double variables for:
i. Standard Hours Worked
ii. Rate of Pay
iii. Overtime Hours (if applicable)
b. Calculate appropriate pay for standard hours and overtime (1.5 x rate of pay).
c. Provide formatted output using the following methods:
i. setw()
ii. setprecision()
2. Variables: Store the values into three different variables. For each variable, create three integer pointers that point to each of the values. Display the contents of the variables and pointers. In your program, be sure to use the new operator and delete operators to manage dynamic memory.

Explanation / Answer

1. Employee Salary Calculator:

#include <iostream> //Header file for standard input/output.

#include <iomanip> //Header file to include C++ manipulators.

using namespace std;

//Definition of input function.

void input_func(double *ptr1,double *ptr2,double *ptr3)

{

cout<<"Enter standard hour worked by the employee: "; //Prompts the user to enter standard hour worked by the employee.

cin>>*ptr1; //Takes input from the user.

cout<<"Enter rate of pay of the employee: "; //Prompts the user to enter the rate of pay of the employee.

cin>>*ptr2; //Takes input from the user.

cout<<"Enter a worked by the employee: "; //Prompts the user to enter over time worked by the employee.

cin>>*ptr3; //Takes input from the user.

}

//Definition of function to calculate total salary.

double calc_salary(double stdHourWorked,double rateOfPay,double overtimeHours)

{

double totalSal;

totalSal = (stdHourWorked * rateOfPay) + (overtimeHours * rateOfPay * 1.5); //Total salary is calculated by adding standard salary and amount earned by doing overtime.

return totalSal;

}

//Definition of function to output total salary.

void output_func(double totalSalary)

{

//Printing the output.

cout<<" Total salary of the employee is: Rs. "<< fixed << showpoint<<setprecision(2)<<totalSalary;

}

int main()

{

double stdHourWorked,rateOfPay,overtimeHours; //variables declared.

//Declaration of function to accept inputs from the user.

//The function has three parameters and is of void type.

//We have passed the address of the three variables created above to accept inputs by reference.

input_func(&stdHourWorked,&rateOfPay,&overtimeHours);

double totalSalary; //Declaration of variable to store total calculated variable.

//Declaration of function to calculate the total salary of the employee.

//Function has three parameters and it returns the total salary calculated.

totalSalary = calc_salary(stdHourWorked,rateOfPay,overtimeHours);

//Declaration of function to print the output.

//Function has one parameter and is of void type.

output_func(totalSalary);

return 0;

}