Prompt
Answer
Pseudocode for Employee Management System
The pseudocode below translates the provided C++ code into human-readable pseudocode that adheres to common programming conventions and structures.
Constants and Class Definition
CONSTANT MAX_LENGTH = 100
CLASS Employee:
ATTRIBUTES:
INTEGER empId
CHAR ARRAY empName[MAX_LENGTH]
CHAR ARRAY fatherName[MAX_LENGTH]
CHAR ARRAY motherName[MAX_LENGTH]
CHAR ARRAY rank[MAX_LENGTH]
CHAR ARRAY department[MAX_LENGTH]
CHAR ARRAY doj[9]
CHAR ARRAY houseNo[MAX_LENGTH]
CHAR ARRAY streetName[MAX_LENGTH]
CHAR ARRAY city[MAX_LENGTH]
CHAR ARRAY state[MAX_LENGTH]
CHAR ARRAY country[MAX_LENGTH]
INTEGER pin
POINTER to Employee next
FUNCTION Constructor:
INPUT: INTEGER id, CHAR ARRAY name, CHAR ARRAY father, CHAR ARRAY mother, CHAR ARRAY rnk, CHAR ARRAY dept, CHAR ARRAY date,
CHAR ARRAY house, CHAR ARRAY street, CHAR ARRAY cty, CHAR ARRAY st, CHAR ARRAY cntry, INTEGER p
SET empId = id
SET empName to name with length MAX_LENGTH
SET fatherName to father with length MAX_LENGTH
SET motherName to mother with length MAX_LENGTH
SET rank to rnk with length MAX_LENGTH
SET department to dept with length MAX_LENGTH
SET doj to date with length 8
SET houseNo to house with length MAX_LENGTH
SET streetName to street with length MAX_LENGTH
SET city to cty with length MAX_LENGTH
SET state to st with length MAX_LENGTH
SET country to cntry with length MAX_LENGTH
SET pin = p
SET next = NULL
Utility Functions
FUNCTION isLeapYear:
INPUT: INTEGER year
RETURN TRUE if year is divisible by 4 and not 100 OR divisible by 400
ELSE RETURN FALSE
FUNCTION isValidDate:
INPUT: CHAR ARRAY date
VERIFY date length is 8
VERIFY date characters are all digits
PARSE date into INTEGER day, month, year
VERIFY year is between 1950 and 2024
VERIFY month is between 1 and 12
VERIFY day is valid for the given month considering leap years
RETURN TRUE if all conditions are met
ELSE RETURN FALSE
FUNCTION isValidName:
INPUT: CHAR ARRAY str
RETURN TRUE if all characters in str are alphabets or spaces
ELSE RETURN FALSE
FUNCTION isValidEmpId:
INPUT: INTEGER empId
RETURN TRUE if empId is a 6-digit number
FUNCTION isValidPin:
INPUT: INTEGER pin
RETURN TRUE if pin is a 6-digit number
FUNCTION createEmployee:
INPUT: INTEGER empId, CHAR ARRAY empName, CHAR ARRAY fatherName, CHAR ARRAY motherName, CHAR ARRAY rank,
CHAR ARRAY department, CHAR ARRAY doj, CHAR ARRAY houseNo, CHAR ARRAY streetName, CHAR ARRAY city,
CHAR ARRAY state, CHAR ARRAY country, INTEGER pin
RETURN NEW Employee initialized with inputs
FUNCTION isDuplicate:
INPUT: POINTER head, INTEGER empId
WHILE head is not NULL
IF head->empId equals empId
RETURN TRUE
MOVE head to head->next
RETURN FALSE
CRUD Operations
FUNCTION insertRecord:
INPUT: POINTER & head, INTEGER empId, CHAR ARRAY empName, CHAR ARRAY fatherName, CHAR ARRAY motherName,
CHAR ARRAY rank, CHAR ARRAY department, CHAR ARRAY doj, CHAR ARRAY houseNo, CHAR ARRAY streetName,
CHAR ARRAY city, CHAR ARRAY state, CHAR ARRAY country, INTEGER pin
SET newEmp = createEmployee with inputs
IF head is NULL OR head->empId > empId
SET newEmp->next = head
SET head = newEmp
ELSE
INITIALIZE temp = head
WHILE temp->next is not NULL AND temp->next->empId < empId
MOVE temp to temp->next
SET newEmp->next = temp->next
SET temp->next = newEmp
OUTPUT "Record inserted successfully."
FUNCTION deleteRecord:
INPUT: POINTER & head, INTEGER empId
INITIALIZE temp = head
INITIALIZE prev = NULL
WHILE temp is not NULL AND temp->empId not equals empId
SET prev = temp
MOVE temp to temp->next
IF temp is not NULL
IF prev is NULL
SET head = temp->next
ELSE
SET prev->next = temp->next
DELETE temp
OUTPUT "Record deleted successfully."
ELSE
OUTPUT "Employee ID not found."
FUNCTION updateRecord:
INPUT: POINTER head, INTEGER empId
INITIALIZE temp = head
WHILE temp is not NULL
IF temp->empId equals empId
PROMPT user and UPDATE temp's attributes with validation
OUTPUT "Record updated successfully."
RETURN
MOVE temp to temp->next
OUTPUT "Employee ID not found."
Display, Search, and File Operations
FUNCTION displayRecords:
INPUT: POINTER head
IF head is NULL
OUTPUT "No records found."
ELSE
INITIALIZE temp = head
WHILE temp is not NULL
OUTPUT temp's attributes
MOVE temp to temp->next
FUNCTION searchRecord:
INPUT: POINTER head, INTEGER empId
WHILE head is not NULL
IF head->empId equals empId
OUTPUT head’s attributes
RETURN
MOVE head to head->next
OUTPUT "Employee ID not found."
FUNCTION saveToFile:
INPUT: POINTER head, CHAR ARRAY filename
OPEN file for writing
IF file not opened successfully
OUTPUT "Error opening file for writing."
RETURN
INITIALIZE temp = head
WHILE temp is not NULL
WRITE temp's attributes to file
MOVE temp to temp->next
CLOSE file
OUTPUT "Database saved to file successfully."
FUNCTION loadFromFile:
INPUT: POINTER & head, CHAR ARRAY filename
OPEN file for reading
IF file not opened successfully
OUTPUT "Error opening file for reading."
RETURN
INITIALIZE empId, empName[MAX_LENGTH], fatherName[MAX_LENGTH], motherName[MAX_LENGTH], rank[MAX_LENGTH], department[MAX_LENGTH],
doj[9], houseNo[MAX_LENGTH], streetName[MAX_LENGTH], city[MAX_LENGTH], state[MAX_LENGTH], country[MAX_LENGTH], pin
WHILE reading from file
READ empId and other attributes
insertRecord with read attributes
CLOSE file
OUTPUT "Database loaded from file successfully."
Main Program
START:
INITIALIZE Employee pointer head to NULL
LOOP until choice is 8
DISPLAY menu
READ choice
SWITCH on choice:
CASE 1:
PROMPT for Employee attributes
INSERT record after validation
CASE 2:
PROMPT for Employee ID
DELETE record
CASE 3:
PROMPT for Employee ID
UPDATE record
CASE 4:
PROMPT for Employee ID
SEARCH record
CASE 5:
DISPLAY all records
CASE 6:
SAVE to file
CASE 7:
LOAD from file
CASE 8:
OUTPUT "Exiting the program."
DEFAULT:
OUTPUT "Invalid choice."
CLEAN UP dynamically allocated memory by deleting all nodes in linked list
END
Description
This pseudocode outlines an Employee Management System, detailing employee attributes, utility functions for validation, CRUD operations for record management, and procedures for displaying, searching, and file operations, all structured for clarity and readability.
More Pseudo Code Generators
Apache Flink Pseudo Code Generator Apache Pig Pseudo Code Generator Azure Data Factory Pseudo Code Generator C/C++ Pseudo Code Generator CouchDB Pseudo Code Generator DAX Pseudo Code Generator Excel Pseudo Code Generator Firebase Pseudo Code Generator Google BigQuery Pseudo Code Generator Google Sheets Pseudo Code Generator GraphQL Pseudo Code Generator Hive Pseudo Code Generator Java Pseudo Code Generator JavaScript Pseudo Code Generator Julia Pseudo Code Generator Lua Pseudo Code Generator M (Power Query) Pseudo Code Generator MATLAB Pseudo Code Generator MongoDB Pseudo Code Generator Oracle Pseudo Code Generator PostgreSQL Pseudo Code Generator Power BI Pseudo Code Generator Python Pseudo Code Generator R Pseudo Code Generator Redis Pseudo Code Generator Regex Pseudo Code Generator Ruby Pseudo Code Generator SAS Pseudo Code Generator Scala Pseudo Code Generator Shell Pseudo Code Generator SPSS Pseudo Code Generator SQL Pseudo Code Generator SQLite Pseudo Code Generator Stata Pseudo Code Generator Tableau Pseudo Code Generator VBA Pseudo Code Generator