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

Write a complete C++ program to process payroll statistics for the ACME Widget C

ID: 3649611 • Letter: W

Question

Write a complete C++ program to process payroll statistics for the ACME Widget Company.
? maximum of 12 employees.
o use an array of structure variables to store the collection of individual employee payroll attributes.
? read the employee payroll attributes from a text file whose file name is entered at the command line.
o if no file name is specified then prompt the user for the file name.
? Each line in the file contains attributes for one employee (no blank lines).
o NAME HOURS RATE
Data File Example: // free format layout
Tom 33 9.75 // 0 or more blanks in front of the name field
Mary 26 10.15 // 1 or more blanks in front of the other fields

Explanation / Answer

/* define template */ struct Person { char ssn[12] ,last_name[20] ,first_name[16] ,street[20] ,city[20] ,state[3] ,zip_code[11] ; int age; float height ,weight ; double salary; }; In the C language, a variable of the above data type would be declared as follows: Fig. 9-3 main() { /* declare variable of structure person type */ struct Person frank; ... } In the C++ language, the use of the keyword struct would not be required in the declaration of a variable of the above type. Fig. 9-4 main() { // declare variable of structure person type Person frank; ... } Each member of a structure is in a contiguous memory location in relationship to its previous member and next member. To access individual members of a structure, the dot operator is used to connect a variable name with an element in the structure. For example frank.last_name The composed name is treated as a variable of with the type of the member variable. Fig. 9-5 #include int main() { struct Person ralph; printf( " Enter your first name:" ); gets( ralph.first_name ); . . . printf( " Enter your age:" ); scanf( "%d", &ralph.age ); return 0; } or in C++ Fig. 9-6 #include int main() { Person ralph; cout > ralph.first_name; . . . cout > ralph.age; 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