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

Complete the C++ program for Payroll of Employees do the folowing: 1. Print the

ID: 3869451 • Letter: C

Question

Complete the C++ program for Payroll of Employees do the folowing:

1. Print the following header at the top of the output page:

Hills Corporation Payroll

2. Read an unknown number of employee data records as shown below. Each group of data will contain employee's first and last name, hours worked, rate of pay and age. A typical group of data will be:

O'Doyle Tom

45.00 3.25 51

Print the data as it is read; together with appropiate message (e.g., the name is...., the rate of pay is.....,etc).

3. For each employee, compute and print the employee's base pay, which includes overtime( paid at one and half times the normal rate) for each hour over 40. For example, if an employee earning $20.00 per hour works for 48 hours, then she will be paid for 40 hours at her normal rate plus 8 extra hours at $30.00 (one and a half times $20.00).

My outfile :

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;

int main ()
{
   ifstream infile;
   infile.open ("hillscorp.txt");
  
   //Check for error
   if (infile.fail() {
       cerr<< "Error Opening file" << endl;
       exit (1);
}
  

Explanation / Answer

Answer for the given Question:

As per given in the problem statement written the below c++ code.

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
const int NAME_SIZE = 51;
struct records {
public:
char name[NAME_SIZE];
int hours;
double rate;
int age;
};
int main() {
cout << "Hills Corporation Payroll" << endl;
ifstream infile; // Declare input file
infile.open("hillscorp.txt", ios::in); // Open input file
// Check for error opening input file
if (infile.fail())
{
cout << "Error opening file; program halted." << endl;
return 0;
}
records employee;
infile.read(reinterpret_cast<char *>(&employee),sizeof(employee));
while (!infile.eof()){
cout << "Name:t" << employee.name << endl;
cout << "Hours worked:t" << employee.hours << endl;
cout << "Rate of pay:t" << employee.rate << endl;
cout << "Age:t" << employee.age << endl;
cout << endl;
infile.read(reinterpret_cast<char *>(&employee),sizeof(employee));
}
infile.close(); // Close input file
cout << "The payroll program is complete.";
return 0; // Close main program function
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote