Question: screen shots of both input and output please! Create a program in C that calculates the paycheck amounts for four employees and shows the average
Create a program in C that calculates the paycheck amounts for four employees and shows the average paycheck amount. Define the an employee struct and declare function prototypes in an .h file. Write the rest of the code in on file, including a main method that serves as a driver. You do not need to take user input; all the data can be hard. coded in main(). Create an array of instances of the struct on the "heap" using malloc(). Write a function called addEmployee() that takes a name, an hourly wage, and a number of hours worked, creates a struct instance with these values, and returns a pointer to the struct instance.. Write a method called calcPaychecks() that uses a for loop to iterate through the structs in the array, getting the name, hourly pay, and number of hours worked for each employee and printing this data, and then prints the average (mean) total pay. Make sure you stop iterating through the arrays when you reach the last employee (for example, if the size of the arrays is four, but there are only three employees, you don't show a default value or include it in the average calculation) main() should call the other functions as follows: call addEmployee() three times, each time taking the new employee record and adding it to the array. Use some reasonable data (for example "Bob Smith", 20.94, 40) call calcPaychecks() The output should look similar to this: Bob Smith, wage 21.00, hours 21 , total pay: $441 Sue Jones, wage 22.30, hours 12 , total pay: $267.60 Carlos Suarez, walze 21.55 hours 15, total pay: $323.25 Average paycheck: $343.40
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
