0% found this document useful (0 votes)
7 views32 pages

Humana

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views32 pages

Humana

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

PAYROLL SYSTEM

USING C LANGUAGE

Submitted to:
Mr. Arlene Baldelovar

Submitted by:
James David A. Casocot
Chosen Grace S. Awiten

COMPUTER PROGRAMMING 1
PROGRAM DESCRIPTION

The Employee Management System is a comprehensive program designed to manage

employee records efficiently, offering functionalities like adding, editing, deleting, searching

for employees, viewing payroll details, and generating payslips. Upon startup, the program

presents a welcome screen with the current date and time, followed by a login prompt for users

to enter a valid username and password. If the credentials are correct, users are granted access

to the main menu, where they can choose from several options, including adding a new

employee, viewing employee payroll, editing existing employee details, deleting employee

records, searching for employees, and generating payslips. Employee details, such as ID, name,

position, daily rate, hours worked, and deductions, are stored in a file.

When adding an employee, the program calculates the gross salary, deductions, and net

pay before saving the data to the file. For editing or deleting employee records, the program

uses file handling techniques to read the original file, modify the required data, and write the

changes to a temporary file, which replaces the original file. The payroll option allows users to

view all employee records, including their salary, deductions, and net pay, while the search

function enables the user to find specific employees by ID. The program can also generate and

display payslips, which include salary details. Once the user opts to exit, the system displays a

farewell message and closes. Designed to handle employee data securely, the system ensures

safe data management through login authentication and reliable file operations.
ALGORITHM

1. Start
2. Declare Variables:
• Create an employee structure to store employee details.
• Declare a global employee variable (e.g., struct employee emp).
• Declare file pointers (e.g., FILE fp, temp_fp).
• Declare variables for user input (e.g., int choice, int emp_id, char uname[10],
char pword[10]).
3. Welcome Screen:
• Display a welcome message with the current date and time.
• Wait for the user to press any key to continue.
4. User Login:
• Prompt the user to input a username and password.
• Validate the credentials:
➢ If valid, display a loading screen and proceed to the main menu.
➢ If invalid, allow up to three attempts before exiting the program.
5. Display Main Menu:
• Show options:
1. Add Employee.
2. View Payroll.
3. Edit Employee.
4. Delete Employee.
5. Search Employee.
6. Generate Payslip.
7. Exit.
• Read the user's choice and call the corresponding function.
6. Add Employee:
• Open the file EmployeeData.dat in append mode.
• Prompt the user to input employee details:
➢ Employee ID, name, position, daily rate, hours worked, SSS
deduction, PhilHealth deduction, and cash advance.
• Calculate:
➢ Gross salary = hours_worked × daily_rate.
➢ Total deductions = sss_deduction + philhealth_deduction +
cashAd_deduction.
➢ Net pay = gross_salary - deductions.
• Write the employee details to the file using fprintf.
• Close the file.
7. View Payroll:
• Open the file EmployeeData.dat in read mode.
• If the file is empty, display a "No records found" message.
• Otherwise, read each employee's data using a loop and display their payroll
details in a table format.
• Close the file.
8. Edit Employee:
• Open the file EmployeeData.dat in read mode and a temporary file in write
mode.
• Prompt the user for the Employee ID to edit.
• Search for the record:
➢ If found, prompt the user to edit the details, recalculate salary and
deductions, and write the updated data to the temporary file.
➢ If not found, write the original data to the temporary file.
• Replace the original file with the temporary file.
• Close both files.

9. Delete Employee:
• Open the file EmployeeData.dat in read mode and a temporary file in write
mode.
• Prompt the user for the Employee ID to delete.
• Copy all records except the one to delete to the temporary file.
• Replace the original file with the temporary file.
• Close both files.
10. Search Employee:
• Open the file EmployeeData.dat in read mode.
• Prompt the user for the Employee ID to search.
• If found, display the employee's details.
• If not found, display a "Record not found" message.
• Close the file.
11. Generate Payslip:
• Open the file EmployeeData.dat in read mode.
• Read and display each employee's payslip one at a time.
• Allow the user to navigate to the next payslip or return to the main menu.
• Close the file.
12. Exit the Program:
• Display a message and terminate the program.
13. End
FLOWCHART
PROGRAM SOURCE CODE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <windows.h>
#include <time.h>

#define ENTER 13
#define BKSP 8
#define SPACE 32
#define TAB 9
#define BAR_LENGTH 50

struct employee {
char name[40], position[20];
int emp_id;
float hours_worked, daily_rate;
float gross_salary, deductions, sss_deduction, philhealth_deduction, cashAd_deduction,
net_pay;
};

struct employee emp;

void setcolor(int color);


void gotoxy(short x, short y);
void welcome(void);
void login(void);
void menu(void);
void add_employee(void);
void view_payroll(void);
void edit_employee(void);
void delete_employee(void);
void search_employee(void);
void payslip(void);

int main(void) {
welcome();
login();
}

void setcolor(int color) {


SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}

void gotoxy(short x, short y) {


COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

void print_centerNdelayed(char *text, int width, int delay) {


int padding = (width - strlen(text)) / 2;

printf("%*s", padding, "");

while (*text) {
putchar(*text);
fflush(stdout);
Sleep(delay);
text++;
}

void welcome(void) {
time_t t;
time(&t);
char* ctime_str = ctime(&t);
ctime_str[strlen(ctime_str) - 1] = '\0';

system("cls");
setcolor(11);
print_centerNdelayed("___________________________________________________\n",
230, 2);
print_centerNdelayed("| |\n", 230, 2);
printf("\t\t\t\t\t\t\t\t\t\t\t | %s |\n", ctime_str);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| WELCOME TO PAYROLL SYSTEM |\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| PRESS ANY KEY TO CONTINUE |\n", 230, 2);
print_centerNdelayed("|_________________________________________________|\n",
230, 2);
getch();

system("cls");
}

void login(void) {
char uname[10], pword[10];
int attempts = 0;
int progress = 0;
int step = 1, i;
char bar[BAR_LENGTH + 1];
int j;
setcolor(11);
system("cls");

print_centerNdelayed("________________________________________________________
_________\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| PAYROLL SYSTEM |\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| LOGIN YOUR ACCOUNT |\n", 230,
2);
print_centerNdelayed("
|_______________________________________________________________|\n\n", 230, 2);

while (attempts < 3) {


print_centerNdelayed("USERNAME: ", 230, 10);
scanf("%s", uname);

print_centerNdelayed("PASSWORD: ", 230, 10);


int i = 0;
char ch;
while ((ch = getch()) != ENTER) {
if (ch == BKSP && i > 0) {
i--;
printf("\b \b");
} else if (ch != BKSP) {
pword[i++] = ch;
printf("*");
}
}
pword[i] = '\0';

if (strcmp(uname, "Admin") == 0 && strcmp(pword, "password") == 0) {


system("cls");
for (i = 0; i < BAR_LENGTH; i++) {
bar[i] = ' ';
}
bar[BAR_LENGTH] = '\0';

printf("Loading...\n");

for (i = 0; i <= BAR_LENGTH; i++) {


bar[i] = '_';

system("cls");
printf("\n\n\t\t\t\t\t\t\t\t\tLoading: [");

for (j = 0; j <= i; j++) {


printf("\033[42m \033[0m");
}
for (j = i + 1; j < BAR_LENGTH; j++) {
printf(" ");
}
printf("] %d%%\n", (i * 100) / BAR_LENGTH);
usleep(10000);
}

setcolor(11);
system("cls");

print_centerNdelayed("__________________________________________________
\n",230, 2);
print_centerNdelayed("| |\n",230, 2);
print_centerNdelayed("| WELCOME TO PAYROLL SYSTEM |\n",230,
2);
print_centerNdelayed("| |\n",230, 2);
print_centerNdelayed("| PRESS ANY KEY TO CONTINUE |\n",230, 2);

print_centerNdelayed("|________________________________________________|\n",230,
2);
getch();
system("cls");
menu();
return;
} else {
attempts++;
system("cls");
setcolor(4);

print_centerNdelayed("__________________________________________________
\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| LOGIN FAILED! |\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| PRESS ANY KEY TO TRY AGAIN
|\n", 230, 2);

print_centerNdelayed("|________________________________________________|\n", 230,
2);
getch();
system("cls");
setcolor(11);

if (attempts == 3) {
int i = 5;
setcolor(4);

print_centerNdelayed("__________________________________________________
\n", 230, 2);
print_centerNdelayed("| |\n", 230,
2);
print_centerNdelayed("| You have exceeded the maximum login attempts! |\n",
230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| PRESS ANY KEY TO EXIT |\n", 230, 2);

print_centerNdelayed("|________________________________________________|\n", 230,
2);
getch();

while ( i > 0) {
system("cls");
printf("\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\tThe Program is Exciting in
%d", i);
sleep(1);
i--;
}
exit(0);
}
}
}
}

void menu(void) {
int choice;

while (1) {
system("cls");

printf("_________________________________________________________________\n");
printf("| |\n");
printf("| PAYROLL SYSTEM |\n");
printf("| |\n");
printf("| MAIN MENU |\n");

printf("|_______________________________________________________________|\n\n\n"
);
printf("\n1. Add Employee");
printf("\n2. View Payroll");
printf("\n3. Edit Employee");
printf("\n4. Delete Employee");
printf("\n5. Search Employee");
printf("\n6. Payslip");
printf("\n7. Exit");
printf("\n\nENTER THE NUMBER OF YOUR CHOICE: ");
scanf("%d", &choice);

while (choice < 1 || choice > 7) {


system("cls");

printf("_________________________________________________________________\n");
printf("| |\n");
printf("| PAYROLL SYSTEM |\n");
printf("| |\n");
printf("| MAIN MENU |\n");

printf("|_______________________________________________________________|\n\n\n"
);
printf("\n1. Add Employee");
printf("\n2. View Payroll");
printf("\n3. Edit Employee");
printf("\n4. Delete Employee");
printf("\n5. Search Employee");
printf("\n6. Payslip");
printf("\n7. Exit");
setcolor(4);
printf("\n\nInvalid choice! Enter again: ");
scanf("%d", &choice);
setcolor(11);
}

switch (choice) {
case 1: add_employee(); break;
case 2: view_payroll(); break;
case 3: edit_employee(); break;
case 4: delete_employee(); break;
case 5: search_employee(); break;
case 6: payslip(); break;
case 7:
printf("\nExiting the system...\n");
exit(0);
break;
default:
setcolor(4);
printf("\nInvalid choice! Try again.\n");
scanf("%d", &choice);
setcolor(11);
getch();
}
}
}

void add_employee(void) {
FILE *fp;
char c;

do {
setcolor(11);
system("cls");

printf("_________________________________________________________________\n");
printf("| |\n");
printf("| PAYROLL SYSTEM |\n");
printf("| |\n");
printf("| ADD EMPLOYEE |\n");

printf("|_______________________________________________________________|\n\n");
fp = fopen("EmployeeData.dat", "a+");

if (!fp) {
printf("Error opening file!\n");
getch();
menu();
return;
}

printf("\nEnter Employee ID: ");


scanf("%d", &emp.emp_id);

printf("Enter Employee Name: ");


fflush(stdin);
gets(emp.name);
emp.name[0] = toupper(emp.name[0]);

printf("Enter Position: ");


gets(emp.position);

printf("Enter Rate/Day: ");


scanf("%f", &emp.daily_rate);

printf("Enter Days Worked: ");


scanf("%f", &emp.hours_worked);

printf("Enter SSS Deduction: ");


scanf("%f", &emp.sss_deduction);

printf("Enter PhilHealth Deduction: ");


scanf("%f", &emp.philhealth_deduction);

printf("Enter Cash Advance: ");


scanf("%f", &emp.cashAd_deduction);

emp.gross_salary = emp.hours_worked * emp.daily_rate;


emp.deductions = emp.sss_deduction + emp.philhealth_deduction +
emp.cashAd_deduction;
emp.net_pay = emp.gross_salary - emp.deductions;
fprintf(fp, "%d %s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n", emp.emp_id,
emp.name, emp.position, emp.hours_worked, emp.daily_rate, emp.gross_salary,
emp.sss_deduction, emp.philhealth_deduction, emp.cashAd_deduction, emp.deductions,
emp.net_pay);
fclose(fp);

printf("\nAdd another employee? (Press 'y' if yes and press any key if no): ");
c = getch();
} while (c == 'y' || c == 'Y');

menu();
}

void view_payroll(void) {
FILE *fp;

system("cls");

print_centerNdelayed("________________________________________________________
_________\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| PAYROLL SYSTEM |\n", 230, 2);
print_centerNdelayed("| |\n", 230, 2);
print_centerNdelayed("| EMPLOYEES RECORD |\n", 230, 2);
print_centerNdelayed("
|_______________________________________________________________|\n\n", 230, 2);

fp = fopen("EmployeeData.dat", "r");
if (fp == NULL) {
printf("No records found.\n");
printf("Press any key to return to the main menu...");
getch();
menu();
return;
}

printf("_____________________________________________________________________
___________________________________________________________________________
___________________________________________________________________\n");
printf("\n");
printf(" EMPLOYEES INFORMATION: SALARY:
DEDUCTIONS:\n\n");
printf(" Gross Salary
Total Deductions");
printf("\n %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s
%-15s %-15s\n", "Employee ID", "Employee Name", "Position", "Days Worked",
"Rate/Day", " ", "SSS Deduction", "PhilHealth Deduction", "Cash Advance
Deduction", " ", "Net Pay");

printf("_____________________________________________________________________
___________________________________________________________________________
___________________________________________________________________\n");

while (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f", &emp.emp_id, emp.name,


emp.position, &emp.hours_worked, &emp.daily_rate, &emp.gross_salary,
&emp.sss_deduction, &emp.philhealth_deduction, &emp.cashAd_deduction,
&emp.deductions, &emp.net_pay) != EOF) {
printf("\n %-15d%-15s %-15s %-15.2f %-15.2f %-15.2f %-15.2f %-15.2f
%-15.2f %-15.2f %-15.2f\n", emp.emp_id, emp.name, emp.position, emp.hours_worked,
emp.daily_rate, emp.gross_salary, emp.sss_deduction, emp.philhealth_deduction,
emp.cashAd_deduction, emp.deductions, emp.net_pay);
}
fclose(fp);

printf("\nPress any key to return to the main menu...");


getch();
menu();
}

void edit_employee(void) {
FILE *fp, *temp_fp;
int emp_id, found = 0;
char c;

system("cls");
printf("\n====================== PAYROLL SYSTEM
=========================");

printf("\n============================================================
===========\n");
printf("\n========================= EDIT EMPLOYEE
==============================\n");

fp = fopen("EmployeeData.dat", "r");
if (fp == NULL) {
printf("No records found.\n");
printf("Press any key to return to the main menu...");
getch();
menu();
return;
}

printf("Enter Employee ID to Edit: ");


scanf("%d", &emp_id);
temp_fp = fopen("TempEmployeeData.dat", "w");
if (temp_fp == NULL) {
printf("Error creating temporary file.\n");
fclose(fp);
getch();
menu();
return;
}

while (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f", &emp.emp_id, emp.name,


emp.position, &emp.hours_worked, &emp.daily_rate, &emp.gross_salary,
&emp.sss_deduction, &emp.philhealth_deduction, &emp.cashAd_deduction,
&emp.deductions, &emp.net_pay) != EOF) {
if (emp.emp_id == emp_id) {
found = 1;

printf("\nEmployee Found : %s\n", emp.name);


printf("Position : %s\n", emp.position);
printf("Rate/Day : %.2f\n", emp.daily_rate);
printf("Days Worked : %.2f\n", emp.hours_worked);
printf("SSS Deduction : %.2f\n", emp.sss_deduction);
printf("PhilHealth Deduction : %.2f\n", emp.philhealth_deduction);
printf("Cash Advance : %.2f\n", emp.cashAd_deduction);
printf("\n\n\n\n\n\n\nPress any key to continue...");
getch();

printf("\nEnter new name (current: %s) : ", emp.name);


fflush(stdin);
gets(emp.name);
emp.name[0] = toupper(emp.name[0]);

printf("Enter new position (current: %s) : ", emp.position);


gets(emp.position);

printf("Enter new Rate/Day (current: %.2f) : ", emp.daily_rate);


scanf("%f", &emp.daily_rate);

printf("Enter new Days worked (current: %.2f) : ", emp.hours_worked);


scanf("%f", &emp.hours_worked);

printf("Enter new SSS Deduction (current: %.2f) : ", emp.sss_deduction);


scanf("%f", &emp.sss_deduction);

printf("Enter new PhilHealth Deduction (current: %.2f) : ",


emp.philhealth_deduction);
scanf("%f", &emp.philhealth_deduction);
printf("Enter new Cash Advance (current: %.2f) : ",
emp.cashAd_deduction);
scanf("%f", &emp.cashAd_deduction);

emp.gross_salary = emp.hours_worked * emp.daily_rate;


emp.deductions = emp.sss_deduction + emp.philhealth_deduction +
emp.cashAd_deduction;
emp.net_pay = emp.gross_salary - emp.deductions;

fprintf(temp_fp, "%d %s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
emp.emp_id, emp.name, emp.position, emp.hours_worked, emp.daily_rate,
emp.gross_salary, emp.sss_deduction, emp.philhealth_deduction, emp.cashAd_deduction,
emp.deductions, emp.net_pay);
} else {
fprintf(temp_fp, "%d %s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
emp.emp_id, emp.name, emp.position, emp.hours_worked, emp.daily_rate,
emp.gross_salary, emp.sss_deduction, emp.philhealth_deduction, emp.cashAd_deduction,
emp.deductions, emp.net_pay);
}
}

fclose(fp);
fclose(temp_fp);

if (found) {
remove("EmployeeData.dat");
rename("TempEmployeeData.dat", "EmployeeData.dat");

printf("\nEmployee data updated successfully!\n");


} else {
printf("\nEmployee with ID %d not found.\n", emp_id);
remove("TempEmployeeData.dat");
}

printf("\nPress any key to return to the menu...");


getch();
menu();
}

void delete_employee(void) {
FILE *fp, *temp_fp;
int emp_id, found = 0;

system("cls");
printf("\n====================== PAYROLL SYSTEM
=========================");

printf("\n============================================================
===========\n");
printf("\n========================= DELETE EMPLOYEE
============================\n");

fp = fopen("EmployeeData.dat", "r");
if (fp == NULL) {
printf("No records found.\n");
printf("Press any key to return to the main menu...");
getch();
menu();
return;
}

temp_fp = fopen("TempEmployeeData.dat", "w");


if (temp_fp == NULL) {
printf("Error creating temporary file.\n");
fclose(fp);
getch();
menu();
return;
}

printf("Enter Employee ID to delete: ");


scanf("%d", &emp_id);

while (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f", &emp.emp_id, emp.name,


emp.position, &emp.hours_worked, &emp.daily_rate, &emp.gross_salary,
&emp.sss_deduction, &emp.philhealth_deduction, &emp.cashAd_deduction,
&emp.deductions, &emp.net_pay) != EOF) {
if (emp.emp_id == emp_id) {
found = 1;
printf("\nEmployee with ID %d found and will be deleted.\n", emp_id);
} else {
fprintf(temp_fp, "%d %s %s %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
emp.emp_id, emp.name, emp.position, emp.hours_worked, emp.daily_rate,
emp.gross_salary, emp.sss_deduction, emp.philhealth_deduction, emp.cashAd_deduction,
emp.deductions, emp.net_pay);
}
}

fclose(fp);
fclose(temp_fp);

if (found) {
remove("EmployeeData.dat");
rename("TempEmployeeData.dat", "EmployeeData.dat");
printf("\nEmployee record deleted successfully.\n");
} else {
printf("\nEmployee ID %d not found.\n", emp_id);
remove("TempEmployeeData.dat");
}

printf("\nPress any key to return to the main menu...");


getch(); menu();
}

void search_employee(void) {
FILE *fp;
int emp_id, found = 0;

system("cls");
printf("\n====================== PAYROLL SYSTEM
=========================");

printf("\n============================================================
===========\n");
printf("\n======================== SEARCH EMPLOYEE
=============================\n");

fp = fopen("EmployeeData.dat", "r");
if (fp == NULL) {
printf("No records found.\n");
printf("Press any key to return to the main menu...");
getch();
menu();
return;
}

printf("Enter Employee ID to search: ");


scanf("%d", &emp_id);

while (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f", &emp.emp_id, emp.name,


emp.position, &emp.hours_worked, &emp.daily_rate, &emp.gross_salary,
&emp.sss_deduction, &emp.philhealth_deduction, &emp.cashAd_deduction,
&emp.deductions, &emp.net_pay) != EOF) {
if (emp.emp_id == emp_id) {
found = 1;

printf("_________________________________________________________________\n");
printf("Employees Info:\n\n");
printf(" Employee ID : %d\n", emp.emp_id);
printf(" Employee Name : %s\n", emp.name);
printf(" Position : %s\n\n", emp.position);
printf("_________________________________________________________________\n");
printf("Salary:\n\n");
printf(" Days Worked : %.2f\n", emp.hours_worked);
printf(" Rate/day : %.2f\n\n", emp.daily_rate);
printf(" Gross Salary : %.2f\n", emp.gross_salary);

printf("_________________________________________________________________\n");
printf("Deductions:\n\n");
printf(" SSS Deduction : %.2f\n", emp.sss_deduction);
printf(" PhilHealth Deduction : %.2f\n", emp.philhealth_deduction);
printf(" Cash Advance Deduction : %.2f\n\n", emp.cashAd_deduction);
printf(" Total Deductions : %.2f\n\n", emp.deductions);

printf("_________________________________________________________________\n");
printf(" Net Pay : %.2f\n", emp.net_pay);

printf("_________________________________________________________________\n");
break;
}
}

fclose(fp);

if (!found) {
printf("\nEmployee with ID %d not found.\n", emp_id);
}

printf("\nPress any key to return to the main menu...");


getch();
menu();
}

void payslip(void) {
FILE *fp;
char c;

fp = fopen("EmployeeData.dat", "r");
if (fp == NULL) {
system("cls");
printf("No records found.\n");
printf("Press any key to return to the main menu...");
getch();
menu();
return;
}

if (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f", &emp.emp_id, emp.name,


emp.position, &emp.hours_worked, &emp.daily_rate, &emp.gross_salary,
&emp.sss_deduction, &emp.philhealth_deduction, &emp.cashAd_deduction,
&emp.deductions, &emp.net_pay) != EOF) {
system("cls");
printf("\n====================== PAYROLL SYSTEM
=========================");
printf("\n============================= PAYSLIP
================================\n\n\n");

printf("_________________________________________________________________\n");
printf("Employees Info:\n\n");
printf(" Employee ID : %d\n", emp.emp_id);
printf(" Employee Name : %s\n", emp.name);
printf(" Position : %s\n\n", emp.position);

printf("_________________________________________________________________\n");
printf("Salary:\n\n");
printf(" Days Worked : %.2f\n", emp.hours_worked);
printf(" Rate/day : %.2f\n\n", emp.daily_rate);
printf(" Gross Salary : %.2f\n", emp.gross_salary);

printf("_________________________________________________________________\n");
printf("Deductions:\n\n");
printf(" SSS Deduction : %.2f\n", emp.sss_deduction);
printf(" PhilHealth Deduction : %.2f\n", emp.philhealth_deduction);
printf(" Cash Advance Deduction : %.2f\n\n", emp.cashAd_deduction);
printf(" Total Deductions : %.2f\n\n", emp.deductions);

printf("_________________________________________________________________\n");
printf(" Net Pay : %.2f\n", emp.net_pay);

printf("_________________________________________________________________\n");
} else {
system("cls");
printf("No employee records found!\n");
fclose(fp);
printf("Press any key to return to main menu");
getch();
menu();
}
while(1){
printf("\nPress 'n' for next employee, 'x' to return to return main menu:
");
c = getch();

if (c == 'n' || c == 'N') {
if (fscanf(fp, "%d %s %s %f %f %f %f %f %f %f %f",
&emp.emp_id, emp.name, emp.position, &emp.hours_worked, &emp.daily_rate,
&emp.gross_salary, &emp.sss_deduction, &emp.philhealth_deduction,
&emp.cashAd_deduction, &emp.deductions, &emp.net_pay) != EOF) {
system("cls");
printf("\n====================== PAYROLL
SYSTEM =========================");

printf("\n============================================================
=====\n");
printf("\n================== PAYROLL SYSTEM
=======================\n\n\n");

printf("_______________________________________________________________
__\n");
printf("Employees Info:\n\n");
printf(" Employee ID : %d\n", emp.emp_id);
printf(" Employee Name : %s\n", emp.name);
printf(" Position : %s\n\n", emp.position);

printf("_________________________________________________________________\n");
printf("Salary:\n\n");
printf(" Days Worked : %.2f\n", emp.hours_worked);
printf(" Rate/day : %.2f\n\n", emp.daily_rate);
printf(" Gross Salary : %.2f\n", emp.gross_salary);

printf("_________________________________________________________________\n");
printf("Deductions:\n\n");
printf(" SSS Deduction : %.2f\n", emp.sss_deduction);
printf(" PhilHealth Deduction : %.2f\n", emp.philhealth_deduction);
printf(" Cash Advance Deduction : %.2f\n\n", emp.cashAd_deduction);
printf(" Total Deductions : %.2f\n\n", emp.deductions);

printf("_________________________________________________________________\n");
printf(" Net Pay : %.2f\n", emp.net_pay);

printf("_________________________________________________________________\n");

} else {
system("cls");
printf("\nReached the last employee.\n");
printf("Press any key to return to main menu...\n");
getch();
menu();
}
} else if (c == 'x' || c == 'X') {
menu();
} else {
printf("\nInvalid Choice.\n");
}
}
fclose(fp);
}
PROGRAM OUTPUT (SCREENSHOT)

1. PAYSLIP (INDIVIDUAL RECORD)


2. PAYROLL SUMMARY

You might also like