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

#include <iostream.h> // input output stream header file #include <stdio.h> // s

ID: 3679355 • Letter: #

Question

#include <iostream.h>   // input output stream header file
#include <stdio.h>   // standard input output header file
#include <stdlib.h>     // standard library header file
#include <string.h>   // header file with string function
// #include <conio.h>   // console input output header file
#include <math.h>
// random payroll processing
int main()   // start main
{
int r1;
int i,j,k;
int id, totWorkHrs, totOverTmWorkHrs;
char firstNm[20], lastNm[25], supFN[30], supLN[30];
char alphabets[26] = "abcdefghijklmnopqrstuvwxyz";
FILE *fp;
fp = fopen("E:/Files/stafData.txt", "a+"); // the MS Dos allows only 8 characters for the file name hence staff had been renamed to staf
fprintf(fp, " ID   FirstName       LastName       TotalWorkHours   TotalOverTimeWorkHours   SupervisorFirstName   SupervisorLastName   EmploymentDate ");
for (k = 1; k<= 900; k++)   {
   id = rand() % 99999; // a 5 digit random number
   if ( id % 2 == 0 ) {   // even id
       strcpy(supFN, "Alexandre" );
       strcpy(supLN, "Desplat" );
   } // end then
   else {   // odd id
       strcpy(supFN, "Bruno" );
       strcpy(supLN, "Coulais" );
   } // end else

   j = 0;
   for (i= 6; i<= 20; i++)
       firstNm[j++] = alphabets[rand()%25]; // a first name of 14 characters long - random strings
   j = 0;
   for (i= 7; i<= 25; i++)
       lastNm[j++] = alphabets[rand()%25]; // a last name or sur name of 19 characters long - random strings

   totWorkHrs = rand() % 200001; // a random number between 1 to 200,000
   totOverTmWorkHrs = rand() % 20001;

   fprintf(fp, " %d    %s    %s    %d    %d    %s    %s", id, firstNm, lastNm, totWorkHrs, totOverTmWorkHrs, supFN, supLN);


} // end for k

fclose(fp);
return 0; // exit
} // end of main()

Hi we just learned c++ basics up to encapsulation and classes.

read the content of staffData.txt (1000 entries) and calculate the salary ($) based on: salary = (TotalWorkHours * 15) + (TotalOvertimeWorkHours * 20) Format salary according to the following example: If the salary of a given employee is 2179645,   format as: $2179645.00 (dollar sign prepend and 2 decimal places)
Also format the employment date according to the following example: If the employmentDate is 12:03:2015, format as: December 3, 2015 (month name DD, YYYY) For each staff entry in staffData.txt write the result into a file results.txt in the following format:
ID, FirstName, LastName, SupervisorFirstName, SupervisorLastName, Salary, EmploymentDate (MonthName DD, YYYY)
E.g.
12010, LVQZIEN, BHEWQKFWUQQJFU, Alexandre, Desplat, $2179645.00, December 3, 2015
Each line represents a staff record. Recall: ID, FirstName, LastName,…, EmploymentDate: are represented by a struct in StaffData.h In part B you shall provide implementation in the following: - processStaffData.h/processStaffData.cpp, and staffData.h - output file: results.txt

_________________________________________________________________________________________________________________________________________________

Sample output:
staffData.txt:

12010 LVQZIEN BHEWQKFWUQQJFU 135987 6992 Alexandre Desplat 12:3:2015 17534 TYHAVRVMZX UHOSSEGQ 186201 10520 Alexandre Desplat 12:5:1997 15003 GBYSSYYSMHFBKR KSJGUJNMC 168340 1951 Bruno Coulais 3:27:2003 r

esults.txt 12010, LVQZIEN, BHEWQKFWUQQJFU, Alexandre, Desplat, $2179645.00, December 3, 2015 12862, OLEZWNCDDI, VRAASTZBMYGGJPVZMSWCTREXB, Alexandre, Desplat, $3353235.00, May 2, 2006 16439, QKHPSWDLSQVEECPHO, JNFODOIFAQFEVMLIMJKZVGWMH, Bruno, Coulais, $181945.00, October 4, 2014 17534, T

Explanation / Answer

Here is your program modified to meet your requirements.

#include <iostream.h> // input output stream header file
#include <stdio.h> // standard input output header file
#include <stdlib.h> // standard library header file
#include <string.h> // header file with string function
// #include <conio.h> // console input output header file
#include <math.h>
// random payroll processing
struct emp
{
char dat[40];


long int id, totWorkHrs, totOverTmWorkHrs;

char firstNm[20], lastNm[25], supFN[30], supLN[30];

} employee;
int main() // start main
{
struct emp e;
int datd;
int mon;
int y;
int r1;
int i,j,k;
long int total=0;
char month[30];
char year[60];
FILE *fp,*fp1;
fp = fopen("stafData.txt", "r"); // the MS Dos allows only 8 characters for the file name hence staff had been renamed to staf
fp1 = fopen("resu.txt", "a+");
for(i=1;i<=3;i++)
{ fscanf(fp, "%ld%s%s%ld%ld%s%s%s", &e.id, e.firstNm, e.lastNm, &e.totWorkHrs, &e.totOverTmWorkHrs, e.supFN, e.supLN,e.dat);

total = (e.totWorkHrs * 15) + (e.totOverTmWorkHrs * 20);

mon =( e.dat[0] -48) * 10 + (e.dat[1] - 48) ;
   switch(mon)
   {
       case 1: { strcpy(month,"January ");}
       case 2: { strcpy(month,"February ");}
       case 3: { strcpy(month,"March ");}
       case 4: { strcpy(month,"April ");}
       case 5: { strcpy(month,"May ");}
       case 6: { strcpy(month,"June ");}
case 7: { strcpy(month,"July ");}
case 8: { strcpy(month,"August ");}
case 9: { strcpy(month,"September ");}
case 10: { strcpy(month,"October ");}
case 11: { strcpy(month,"November ");}
case 12: { strcpy(month,"December ");}
}
for(k=0;k <10;k++)
{ year[i] = e.dat[i+2]; }

fprintf(fp1," %ld %s %s %s %s %ld %s , %s", e.id, e.firstNm, e.lastNm, e.supFN, e.supLN,total,month,year);
}
fclose(fp);
fclose(fp1);
return 0; // exit
} // end of main()