0% found this document useful (0 votes)
2 views

JavaScript Documentation

The IQOR Management System is a JavaScript application designed for managing employee records, including functionalities for adding, editing, deleting, and searching employee information. It calculates salaries based on hours worked and employment status, with an interactive menu for user input. The system incorporates error handling and validation to ensure accurate data management and enhances user experience through a structured interface.

Uploaded by

John V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JavaScript Documentation

The IQOR Management System is a JavaScript application designed for managing employee records, including functionalities for adding, editing, deleting, and searching employee information. It calculates salaries based on hours worked and employment status, with an interactive menu for user input. The system incorporates error handling and validation to ensure accurate data management and enhances user experience through a structured interface.

Uploaded by

John V
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

HOLY ANGEL IQOR Management

UNIVERSITY System
School of Computing CS-202

IQOR Management
System
DOCUMENTATION

Submitted by:

Bernarte, Karl Shane

Cabico, John Christian

Ibe, Gian Kyle

Sigua, Carl Jerome

Vender, Joalnes John

Section:
CS-202

Course:
Design and Implementation of Programming Languages

Instructor:
Ma. Louella M. Salenga

1 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

JavaScript CODE
const readline = require("readline-sync");

class Employee {
constructor(id, name, department, status, ratePerHr, hoursWorked, dateHired) {
this.employeeID = id;
this.employeeName = name;
this.department = department;
this.employeeStatus = this.getStatusFromNumber(status);
this.ratePerHr = ratePerHr;
this.hoursWorked = hoursWorked;
this.dateHired = dateHired;
this.Salary();
}

getStatusFromNumber(num) {
const statuses = { "1": "Probational", "2": "Permanent", "3": "Contractual" };
return statuses[num] || "Unknown";
}

Salary() {
let baseMultiplier;
let overtimeRate;

if (this.employeeStatus === "Permanent") {


baseMultiplier = 1.2;
overtimeRate = 2.0;
} else if (this.employeeStatus === "Probational") {
baseMultiplier = 1.1;
overtimeRate = 1.75;
} else {
baseMultiplier = 1.0;
overtimeRate = 1.5;
}

this.grossPay = this.hoursWorked * this.ratePerHr * baseMultiplier;


let overtimeHours = Math.max(0, this.hoursWorked - 40);
this.overtimePay = overtimeHours * this.ratePerHr * overtimeRate;
this.totalPay = this.grossPay + this.overtimePay;
}
}

class EmployeeManager {
constructor() {
this.employees = [];
}

addEmployee(emp) {
this.employees.push(emp);
}

findEmployee(id) {
return this.employees.find(emp => emp.employeeID === id);
}

deleteEmployee(id) {
let index = this.employees.findIndex(emp => emp.employeeID === id);
if (index !== -1) {
this.employees.splice(index, 1);
return true;
}
return false;
}
}

const manager = new EmployeeManager();

function Menu() {
console.log(" IQOR EMPLOYEE MANAGEMENT SYSTEM ");
console.log("==========================================\n");
console.log("1. Add Employee Record");
console.log("2. Edit Employee Information");
console.log("3. Delete Employee Record");
console.log("4. Search Employee");
console.log("5. Exit\n");
}

function handleUserInput() {
let isRunning = true;

2 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

while (isRunning) {
Menu();
let option = readline.question("Enter Option Number [1-5]: ").trim();

switch (option) {
case "1":
addEmployeeRecord();
break;
case "2":
editEmployeeRecord();
break;
case "3":
deleteEmployeeRecord();
break;
case "4":
searchEmployee();
break;
case "5":
console.log("\nExiting Program...");
isRunning = false;
break;
default:
console.log("\nInsert a valid input! Please choose between 1-5.");
break;
}
}
}

function addEmployeeRecord() {
console.log("\n===========Create/Add Employee Information===========\n");

let ID = parseInt(readline.question("Enter Employee ID: "));


let name = readline.question("Enter Employee Name: ");
let department = readline.question("Enter Employee Department: ");

let status;
while (true) {
console.log("\nChoose Employee Status:");
console.log("1. Probational");
console.log("2. Permanent");
console.log("3. Contractual");
status = readline.question("Enter choice [1-3]: ");
if (["1", "2", "3"].includes(status)) break;
console.log("Invalid input! Choose between 1-3.");
}

let rate = parseFloat(readline.question("Enter Employee Rate/Hr (PHP): "));


let hoursWorked = parseFloat(readline.question("Enter Hours Worked: "));
let dateHired = readline.question("Enter Date Hired (MM/DD/YYYY): ");

let newEmployee = new Employee(ID, name, department, status, rate, hoursWorked, dateHired);
manager.addEmployee(newEmployee);
console.log("\nEmployee has been added successfully!\n");
}

function editEmployeeRecord() {
let ID = parseInt(readline.question("\nEnter Employee ID: "));

let emp = manager.findEmployee(ID);


if (!emp) {
console.log("\nEmployee Not Found!\n");
return;
}

console.log("\nEditing Employee Record");


console.log("1. Name");
console.log("2. Department");
console.log("3. Status");
console.log("4. Rate per Hour");
console.log("5. Hours Worked");

let option = readline.question("\nEnter field number: ").trim();

switch (option) {
case "1":
emp.employeeName = readline.question("Enter New Name: ");
break;
case "2":
emp.department = readline.question("Enter New Department: ");
break;
case "3":
while (true) {
console.log("\nChoose New Employee Status:");
console.log("1. Probational");

3 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

console.log("2. Permanent");
console.log("3. Contractual");
let status = readline.question("Enter choice [1-3]: ");
if (["1", "2", "3"].includes(status)) {
emp.employeeStatus = emp.getStatusFromNumber(status);
emp.Salary();
break;
}
console.log("Invalid input! Choose between 1-3.");
}
break;
case "4":
emp.ratePerHr = parseFloat(readline.question("Enter New Rate Per Hour (PHP): "));
emp.Salary();
break;
case "5":
emp.hoursWorked = parseFloat(readline.question("Enter New Hours Worked: "));
emp.Salary();
break;
default:
console.log("Please insert a Valid Input!");
return;
}

console.log("\nEmployee Record Updated!\n");


}

function deleteEmployeeRecord() {
let ID = parseInt(readline.question("\nEnter Employee ID to Delete: "));

if (manager.deleteEmployee(ID)) {
console.log("\nEmployee Deleted Successfully!\n");
} else {
console.log("\nEmployee Not Found!\n");
}
}

function searchEmployee() {
let ID = parseInt(readline.question("\nEnter Employee ID: "));

let emp = manager.findEmployee(ID);


if (!emp) {
console.log("\nEmployee Not Found!\n");
return;
}

console.log("\n===== Employee Details =====");


console.log(`ID: ${emp.employeeID}`);
console.log(`Name: ${emp.employeeName}`);
console.log(`Department: ${emp.department}`);
console.log(`Status: ${emp.employeeStatus}`);
console.log(`Rate Per Hour: PHP ${emp.ratePerHr}`);
console.log(`Hours Worked: ${emp.hoursWorked}`);
console.log(`Date Hired: ${emp.dateHired}`);
console.log(`Gross Pay: PHP ${emp.grossPay.toFixed(2)}`);
console.log(`Overtime Pay: PHP ${emp.overtimePay.toFixed(2)}`);
console.log(`Total Pay: PHP ${emp.totalPay.toFixed(2)}\n`);
}

handleUserInput();

4 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

Overview
The IQOR_Management_System utilizes JavaScript to construct a basic employee management
system for the management of personnel records. Adding, amending, deleting, and searching
employee records are among the primary features. Each employee's pay is also determined by the
system according to their hours worked and status (contractual, permanent, or probationary).

Features
• Add a new employee record

• Edit employee details

• Delete an employee record

• Search for an employee

• Compute gross pay

• Compute overtime pay

• Compute total pay

• Categorize employees by status

• Interactive menu-driven system

• Input validation

Classes and Methods


Employee Class

The Employee class represents an employee and includes methods for calculating salary.

Properties:

● employeeID: The unique identifier of the employee.


● employeeName: The name of the employee.
● department: The department where the employee works.
● employeeStatus: Employment status (Probational, Permanent, Contractual).
● ratePerHr: Hourly wage of the employee.
● hoursWorked: Total hours worked per week.
● dateHired: The date when the employee was hired.
● grossPay: Base salary before overtime pay.
● overtimePay: Compensation for overtime hours worked beyond 40 hours per week.
● totalPay: Gross salary plus overtime pay.

Methods:

● constructor(id, name, department, status, ratePerHr, hoursWorked, dateHired): Initializes


an employee object with given details.
● getStatusFromNumber(num): Converts numeric input (1, 2, 3) to corresponding
employment status.
● Salary(): Computes gross pay, overtime pay, and total pay based on employment status.

5 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

EmployeeManager Class

The EmployeeManager class manages a list of Employee objects.

Methods:

● constructor(): Initializes an empty list of employees.


● addEmployee(emp): Adds an employee to the list.
● findEmployee(id): Searches for an employee by ID and returns the employee object if
found.
● deleteEmployee(id): Removes an employee from the list if found.

Main Program (Menu and User Interaction)

The main program is responsible for handling user input and executing the appropriate actions.

Methods:

● Menu(): Displays the main menu options.


● handleUserInput(): Continuously prompts the user for input and executes the
corresponding action.
● addEmployeeRecord(): Prompts the user for employee details and adds a new record.
● editEmployeeRecord(): Allows the user to modify an existing employee’s details.
● deleteEmployeeRecord(): Removes an employee record based on the given ID.
● searchEmployee(): Finds and displays an employee's information.

Salary Calculation
Base Salary Multiplier

● Permanent: 1.2 times the base salary.


● Probational: 1.1 times the base salary.
● Contractual: 1.0 times the base salary.

Overtime Rate

● Permanent: 2.0 times the hourly rate.


● Probational: 1.75 times the hourly rate.
● Contractual: 1.5 times the hourly rate.

Calculation Formula

GrossPay = HoursWorked * RatePerHr * baseMultiplier

OvertimePay = (HoursWorked − 40) * RatePerHr * OvertimeRate, if


HoursWorked > 40

TotalPay = GrossPay + OvertimePay

6 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

User Interaction Flow


1. Choose one of the 5 options [1-5]

2. Add Employee Record

● Insert Employee record details


● Record is successfully added

3. Edit Employee Record

● Search for Employee ID


● Edit status of employee record
● Record successfully modified and data updated

4. Delete Employee Record

● Search for Employee ID


● Record of Employee completely removed from the system

5. Search Employee

● Search Employee ID
● Display of every available data of Employee
● Includes updatable data of Employee Salary

6. Exit

● Exits the system

Error Handling and Validation


● Ensuring the Menu Option is Between 1-5:

The application checks to see if the menu selection is based on user input that is in
the range of one to five. If the user selected an invalid menu option an error
message will display telling the user to select a valid option. This helps prevent
unintended behaviors and ensures that the user performs the intended menu action.

● Employee Status Selection:

Employee status entries are limited to three valid entries only (1: Probational, 2:
Permanent, 3: Contractual) and will assume an incorrect entry to display a
second prompt.

● Errors when finding an employee:

Whenever you search for an employee, edit an employee, or delete an


employee, the system checks for the existence of the employee ID. If the
employee ID does not exist, the user will receive an error message that states,
"Employee Not Found."

7 | Page
HOLY ANGEL IQOR Management
UNIVERSITY System
School of Computing CS-202

Conclusion
The IQOR Management System is a realistic JavaScript application that demonstrates crucial
employee management features. The system meets essential organizational needs by including
capabilities like record management, salary computation, and status categorization. It effectively
incorporates input validation and an interactive, menu-driven interface to enhance user
experience. The application of object-oriented concepts, particularly the Employee and
EmployeeManager classes, provides a structured approach to managing complex data. Overall,
the project achieves a balance between technical implementation and practical utility.

8 | Page

You might also like