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

Write a C++ program that will read 10 records into an array from a data file. Ea

ID: 3766977 • Letter: W

Question

Write a C++ program that will read 10 records into an array from a data file. Each record should contain an employee ID, hours worked and pay rate. You should calculate a total pay and then write the record to an output file. The Record written should consist of Employee ID, hours worked, pay rate and total pay. Description DataType Variables Employee IDs of INT employees_jd Hours Worked of DOUBLE hrworked_jd Pay Rate of DOUBLE payrate_jd Total Pay of Double total_pay Excluding the main function, your program should have three additional functions that will get the employee id, hours worked, and payrate; another to calculate the total pay; and another to write your output to the output file. Total pay should be calculated by multiplying the hours worked by payrate plus 10% of total pay for every five (5) hours over forty (40). (ie a person working 50 hours with a total pay of $100 would have ((50-40)/5)*(100*.1) added to total pay. Note: _jd represents the initials of the programmer. Your function names should be named by replacing the initials jd with your first and last initials Read Input File Calculate Pay Output Results Name of function get_jd calc_jd prt_jd Properties of function Called from main Called from main Called from main Definition of Function Should pass employee id, hours worked and payrate Should pass hours worked and payrate and calculate total pay Should pass employee id, hours worked, payrate and total pay and write data Using the instructions in Program 12, write the same program. But this time create a file (datafile) that has your full name, Course name and Date on the first three lines. Write the program to open the output file in append mode and write your output to this file. When the execution of your C++ is complete, your output file should contain your name, course name and date followed by the 10 employee records including their total pay.

Explanation / Answer

#include <bits/stdc++.h>
using namespace std;

class Record{
public:
   int employees_id;
   double hrworked;
   double payrate;
   Record(){
       employees_id=0;
       hrworked=0;
       payrate=0;
   }
};

int get_employeeid(Record r){
   return r.employees_id;
}

double get_hrworked(Record r){
   return r.hrworked;
}

double get_payrate(Record r){
   return r.payrate;
}

double totalpay(Record r){
   if(r.hrworked<=40){
       return r.hrworked*r.payrate;
   }
   else{
       return r.hrworked*r.payrate + ((r.hrworked-40)/5)*(r.hrworked*r.payrate*0.1);
   }
}

int main(){
   ifstream inf;
   inf.open("input.txt");
   Record arr[10];
   int eid;
   double whrs;
   double prate;
   for(int i=0;i<10;i++){
       inf>>eid>>whrs>>prate;
       Record r;
       r.employees_id=eid;
       r.hrworked=whrs;
       r.payrate=prate;
       arr[i]=r;
   }
   ofstream outf;
   outf.open("output.txt");
   for(int i=0;i<10;i++){
       outf<<arr[i].employees_id<<" "<<arr[i].hrworked<<" "<<arr[i].payrate<<" "<<totalpay(arr[i])<<endl;
   }
   return 0;
}

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