In: Computer Science
Needs to be written in C
Many universities pay their teaching assistants (TA) or
associate instructors (AI) as weekly workers (who receive a fixed
weekly salary), hourly workers (who receive a fixed hourly wage for
up to the first 10 hours they work and “time-and-a-half”- i.e., 1.5
times their hourly wage - for overtime hours worked), commission
workers (who receive $250 plus 7.1 times their gross weekly work
hours), or pieceworkers (who receive a fixed amount of money for
each of the items they produce - each pieceworker in the university
works on only one type of item). Some TAs may be international
students who are not authorized to work more than 20 hours per
week. Write a program to compute the weekly pay for each worker.
You do not know the number of employees in advance. Each type of
worker has its own pay code: AIs have paycode ‘W’, hourly workers
have code ‘H’, commission workers have code ‘C’ and pieceworkers
have code ‘P’. Use a switch statement to compute each employee’s
pay based on that employee’s paycode. Within the switch, prompt the
user (i.e., the payroll clerk) to enter the number of employees of
each paycode (minimum of 2), and the appropriate facts your program
needs to calculate each employee’s pay based on that employee’s
paycode. [Note: You can input values of type double using the
conversion specifier %lf with scanf.]. The program should start by
displaying a ‘Menu’ like option where you user can enter the
appropriate paycode first along with the number of employees of
that type. Only acceptable paycodes are ‘W’, ‘H’, ‘C’, and ‘P’.
User may enter ‘Q’ to quit the program. Any other choice should
display the menu again. Also display the following
statistics:
• Weekly salary paid to workers who are international
students,
• Weekly salary paid to workers who are domestic students,
• Weekly salary paid to workers with different paycodes.
• Total weekly salary paid to all workers
Note 1: Loops can be written using ‘while’, ‘for’ and ‘do-while’
statements. For this question, you can’t use same loop statement
more than once (For example: if you have to use double nested loop,
you can’t use ‘for’ loop inside a ‘for’ loop. It has to be ‘for’
loop inside a ‘while’ or vice versa or some other
combination)!
Note 2: Your program should be case insensitive. Uppercase and
lowercase inputs will be considered correct!
Note 3: After displaying the salary amounts, show the menu again
automatically. Notice that there will be no other way to stop the
program until user enters Q.
Screenshot -----------------
|
Code ---------------- //////////////////////////////////////////////////////////////////////////////////////////////////// #include struct employee void add(struct employee** head_ref,char* name, double
salary, char wtype, char ltype) int main() ////////////////////////////////////////////////////////////////////////////////////////////////// |
Output ---------------
|