-
Notifications
You must be signed in to change notification settings - Fork 0
/
project5_payroll_calculator.c
91 lines (72 loc) · 2.26 KB
/
project5_payroll_calculator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
3.Write a program that computes the payroll for a company for N employees.
Daily Pay for per employee will be calculated as pay=hours*rate. For each employee,
the number of hours worked per day and the number of days worked a week will be entered by user.
Rates values will be entered by users for each employee.
Program will print the total payroll for company and calculate
the average daily cost of workers and print it on the screen.
*/
#include <stdio.h>
#include <stdlib.h>
int main(void){
// Declared total pay,employee number,work Hour,and i for for loop
int total=0;
int employee=0;
int i=0;
int workH=0;
//Declared all days but not weekends to find each days cost
int mon=0;
int tue=0;
int wed=0;
int thu=0;
int fri=0;
printf("Welcome to the payroll calculator\n");
//Entered the number of employees
printf("Please enter the number of employees=>");
scanf("%d",&employee);
//we use for loop to take each employees rate-workday-workhours
for(i;i<employee;i++){
int rate=0;//declare rate
int dayW=0;//declare worked days
printf("\nPlease enter the %d. employee's rate ",i+1);
scanf("%d",&rate);
printf("\nPlease enter the %d. employee's number of days worked a week=>",i+1);
scanf("%d",&dayW);
printf("\n");
int j=0;//for second for loop
for(j;j<dayW;j++){
int day=0;//To find which day is this given day
int daily=0;//daily pay
printf("Please enter the %d. employees %d. work day and days work hours\n",i+1,j+1);
printf("You can enter days as a number between 1-5\n");
scanf("%d %d",&day, &workH);
daily=rate*workH;
if(day==1){
mon=mon+daily;
}
else if(day==2){
tue=tue+daily;
}
else if(day==3){
wed=wed+daily;
}
else if(day==4){
thu=thu+daily;
}
else if(day==5){
fri=fri+daily;
}
total=total+daily;
}
}
//Display Company costs
printf("Company Total Cost\n");
printf("\nTotal payroll is %d\n\n\n",total);
printf("Monday cost is %d\n",mon);
printf("Tuesday cost is %d\n",tue);
printf("Wednesday cost is %d\n",wed);
printf("Thursday cost is %d\n",thu);
printf("Friday cost is %d\n",fri);
printf("Average daily cost is %d\n",total/5);
return 0;
}