Professional Documents
Culture Documents
Computer Science Unit #1 - Internal Assessment - Isaac Ashton Ramdeen
Computer Science Unit #1 - Internal Assessment - Isaac Ashton Ramdeen
Table of Contents 2
Problem Statement 3
Functional Requirements 5
Non-Functional Requirements 6
Pseudocode 7
Technical Documentation 24
Program Code (C/C++) 25
File Design 39
White Box Testing 40
Results of Whitebox Testing 42
Functional Testing 45
User Documentation 53
Problem Statement
Rashelia Ramdeen Transport & General Contractors, is a well-known business, for civil and
infrastructural works and the supply of a wide variety of aggregates & building materials within
the construction and civil engineering industry of Trinidad & Tobago.
The company, being experienced and well established nationwide, has a numerous amount of job
offers and vacancies towards the public each year, due to the expansion of the construction &
infrastructural sector of the country.
The company currently comprises of 150 employees. The management have been recording the
employees’ payroll and generating the employees’ pay slips manually, by the use of a pen, paper
and calculator.
The staff of the accounting department, have reported to management that the present manual
style of processing & analyzing the employees’ payroll data has become very tedious and
frustrating, as they must physically hand-write each persons’ credentials on every pay slip sheet
and make calculations, for each working week.
This method is also time-consuming, which may lead to a delay with the processing of pay slips
and also errors may be prevalent and can produce inconsistent information.
To create a possible solution for this problem, the management and staff of Rashelia Ramdeen
Transport & General Contractors would like an efficient, computerized system of processing and
analyzing the various data from these employees, for mass production of their pay slips at the
end of working periods.
Sample Pay Slip:
Functional Requirements
● Store the employees’ names, ages, date of pay, National Insurance ID, Pay As You Earn
ID, Health Surcharge IDs & values, hours & days worked, hourly rate of pay and their
respective gross & net salary amounts earned, in an employee structure array and an
“Add Employee” procedure to prompt the user for this data should be developed.
● Calculate the:
⮚ “Gross Salary” by multiplying the ‘hourly rate of pay’ by the amount of ‘hours worked’
and then multiplying the product by the ‘days worked’.
⮚ “Net Salary” after deducting the following values, from the employees’ “Gross Salary”:
● Export the Employees’ data from the array to a text file called “Employees’ Database”
and add a function to Import data from the text file to store into the program’s array, for
viewing.
● Develop a function, to display all of the employees’ records within the database of the
program, precisely and as well as another procedure to sort these records by the
employees’ “Net Salary” values, in descending order, via using the “Bubble Sort”
method.
Non-Functional Requirements
To enhance the design of the program, the following quality system attributes, such as its
performance and usability are included within the program:
● Data Validation:
- As the program prompts the user for data, the inputs must be verified, by procedures to
ensure that it meets the desired output. This is to guarantee that all the information in the
employees’ database is accurate and precisely entered by the user.
DECLARE MAX_EMPS 50
Narrative Description:
- The two structures below are the pay date struct which stores the information of day,
month and year in an array and the employee struct, which stores the employee’s data in
an array, to be declared.
STRUCT Pay Date
int day
int month
int year
STRUCT Employee
char fname[30]
char lname[30]
int hrs
int days
int rate
int insuranceNo
int insuranceValue
int payeValue
int payeNo
int healthValue
int healthNo
int grossSalary
int netSalary
FUNCTION add_employee()
BEGIN
system ("cls")
system ("color 4E")
if (num_emps == MAX_EMPS)
then
OUTPUT ("Error: maximum number of employees reached")
end if
OUTPUT("Enter date, in which the Salary was received , in the format: DD/MM/YYYY ")
DECLARE int day, month, year
while (INPUT("%d/%d/%d", &day, &month, &year)
!= 3 || day < 1 || day > 31 || month < 1 || month > 12|| year < 1900 || year > 2050)
do
OUTPUT ("Error: invalid date format. Please enter the date in the format
DD/MM/YYYY: ")
DECLARE c
while ((c = getchar()) != '' && c != EOF)
emp[num_emps].date.day = day
emp[num_emps].date.month = month
emp[num_emps].date.year = year
system ("pause")
system ("cls")
OUTPUT ("SECTION 1 - First & Last Names and Hours & Days Worked")
OUTPUT ("Please ensure that the Employee's First & Last Names ")
OUTPUT ("are spelt correctly and the amount of letters in ")
OUTPUT ("his/her names, should not exceed 30 characters,")
OUTPUT ("as well as their work days and hours, which should not ")
OUTPUT ("exceed seven (7) days, per week or twelve (12) hours, per day.")
OUTPUT ("and their rate of pay should be over minimum wage. thank you!")
DECLARE valid = 'N'
do
OUTPUT("Enter First Name: ")
INPUT("%s", tempFname)
while
(valid == 'N')
emp[num_emps].days = tempDays
DECLARE emp[num_emps].payeValue = 10
DECLARE emp[num_emps].healthValue =
DECLARE emp[num_emps].insuranceValue = 11
system ("pause")
system ("cls")
system ("color 4F")
OUTPUT ("SECTION 2 - National Insurance, Pay As You Earn & Health Surcharge ID#")
OUTPUT ("Please ensure that the Employee's NIB, PAYE & Health Surcharge IDs are")
OUTPUT ("correct and the amount of numbers in")
OUTPUT (" the identification, should not exceed 15 numbers,thank you!")
do
OUTPUT("Enter Health Surcharge number: ")
INPUT("%s", &tempHealth)
if (strlen(tempHealth) > 15)
then
OUTPUT("Error: Health Surcharge number must be no more than 15 digits")
else
valid = 'Y'
endif
while
(valid == 'N')
emp[num_emps].healthNo = atol(tempHealth)
system ("pause")
system("cls")
system("color 2F")
OUTPUT("SECTION 3 - NIB, PAYE & Health Surcharge Weekly Rates for Deduction")
OUTPUT("Please ensure that the Employee's NIB, PAYE & Health Surcharge values are")
OUTPUT("correct and if the amount stated is not, according to your ")
OUTPUT(" National Insurance Board's Insurance system, feel free to ammend the taxes thank
you!")
system("pause")
num_emps++
Narrative Description:
- This procedure sorts employees by salary in descending order, by the use of a nested
"for"loop condition combined with an "if" statement, which is commonly known as the
"Bubble Sort" function, which is an algorithm that works, by repeatedly swapping the
adjacent elements if they are in the wrong order (descending order).
FUNCTION sort_employees()
BEGIN
system ("cls")
system ("color 42")
DECLARE int i, j
for (i = 0 i < num_emps-1 i++)
do
for (j = 0 j < num_emps-i-1 j++)
do
if (emp[j].netSalary < emp[j+1].netSalary)
then
Employee temp = emp[j]
emp[j] = emp[j+1]
emp[j+1] = temp
endif
OUTPUT("Employees sorted by total salary")
system ("pause")
END
Narrative Description:
- This procedure, displays all of the employees which were stored in the employees’ array.
FUNCTION display_all_employees()
BEGIN
system ("cls")
system ("color 24")
DECLARE int i
for (i = 0 i < num_emps i++)
do
OUTPUT("Employee #%d", i + 1)
OUTPUT("Pay Date : %02d/%02d/%04d", emp[i].date.day, emp[i].date.month,
emp[i].date.year)
OUTPUT("First Name: %s", emp[i].fname)
OUTPUT("Last Name : %s", emp[i].lname)
OUTPUT("Gross Salary : $%d", emp[i].grossSalary)
OUTPUT("NIB Number : #%d", emp[i].insuranceNo)
OUTPUT("NIB Value Deduction : $%d", emp[i].insuranceValue)
OUTPUT("PAYE Number : #%d", emp[i].payeNo)
OUTPUT("PAYE Value Deduction : $%d", emp[i].payeValue)
OUTPUT("Health Surcharge Number : #%d", emp[i].healthNo)
OUTPUT("Health Surcharge Value Deduction : $%d", emp[i].healthValue)
OUTPUT("Total Net Salary : $%d", emp[i].netSalary)
system ("pause")
END
Narrative Description:
- This procedure takes all of the data entered by the user for the employees' records and
'sends or 'exports them to a .txt file named "Employee_Database.txt" The file is called by
the function "FILE *outputFile = fopen (name.txt/w) where the "w" variable opens the
file in write mode. It also includes a validation if the file could not be opened and prints
an error message
FUNCTION export_employees_to_file()
BEGIN
system ("color 4F")
FILE *outputFile = fopen("Employee_Database.txt", "w")
if (outputFile == NULL)
then
OUTPUT("Error: could not open file for writing")
return
OUTPUT(outputFile, "%d", num_emps)
for (int i = 0 i < num_emps i++)
do
OUTPUT(outputFile, "%s", emp[i].fname)
OUTPUT(outputFile, "%s", emp[i].lname)
OUTPUT(outputFile, "%d", emp[i].hrs)
OUTPUT(outputFile, "%d", emp[i].days)
OUTPUT(outputFile, "%d", emp[i].rate)
OUTPUT(outputFile, "%d", emp[i].insuranceNo)
OUTPUT(outputFile, "%d", emp[i].insuranceValue)
OUTPUT(outputFile, "%d", emp[i].payeNo)
OUTPUT(outputFile, "%d", emp[i].payeValue)
OUTPUT(outputFile, "%d", emp[i].healthNo)
OUTPUT(outputFile, "%d", emp[i].healthValue)
OUTPUT(outputFile, "%d", emp[i].grossSalary)
OUTPUT(outputFile, "%d", emp[i].netSalary)
OUTPUT(outputFile, "%02d/%02d/%04d", emp[i].date.day, emp[i].date.month,
emp[i].date.year)
OUTPUT(outputFile, "")
CLOSE (outputFile)
Narrative Description:
- This procedure retrieves the data entered by the user from the employees' .txt file named
"Employee_Database.txt" and the program 'receives or 'imports them this file, to store
the data into the employee array. The file is called by the function "FILE *inputFile =
fopen (name.txt/w) where the "w" variable opens the file in write mode. It also includes a
validation if the file could not be opened and prints an error message
FUNCTION import_employees_from_file()
BEGIN
system ("color 42")
FILE *inputFile = fopen("Employee_Database.txt", "r")
if (inputFile == NULL) {
OUTPUT("Error: could not open file for reading")
return
DECLARE int num_imported = 0
INPUT(inputFile, "%d", &num_imported)
FUNCTION main_menu()
BEGIN
system ("cls")
system ("color 47")
DECLARE int choice
while (1)
system("cls")
OUTPUT("MAIN MENU")
OUTPUT("******************************************")
OUTPUT("1. Add New Employee")
OUTPUT("******************************************")
OUTPUT("2. Sort Employees by Total Salary")
OUTPUT("******************************************")
OUTPUT("3. Display All Employees")
OUTPUT("******************************************")
OUTPUT("4. Export Employees")
OUTPUT("******************************************")
OUTPUT("5. Import Employees")
OUTPUT("******************************************")
OUTPUT("6. Exit")
OUTPUT("******************************************")
OUTPUT("Please Enter your choice: ")
INPUT("%d", &choice)
do
switch (choice)
{
case 1:
add_employee()
break
case 2:
sort_employees()
break
case 3:
display_all_employees()
break
case 4:
export_employees_to_file()
break
case 5:
import_employees_from_file()
break
case 6:
goodbye()
return
else
default:
OUTPUT("Invalid choice")
system ("pause")
BEGIN of main
DECLARE int main (void)
welcome()
main_menu()
END of main
Technical Documentation
The following portrays a Hierarchical Input Process Output Chart (HIPO), which organizes the
payroll program’s system modules (tasks) into a hierarchy (levels), according to the “Top-
Down” principle of problem-solving:
Program Code (C/C++)
File Design
Variable Name Data Length Description Sample Data
Type
Employee Structure Array
fname char 30 Stores the employee’s first name John
in the array
lname char 30 Stores the employee’s last name Dickinson
in the array
hrs int 2 Stores the number of days worked 8
by the employee in the array
days int 1 Stores the number of days worked 5
by the employee in the array
rate int 2 Stores the hourly pay rate of 40
employee in the array
insuranceNo int 16 Stores employee’s NIS ID in the 11254
array
payeNo int 16 Stores employee’s PAYE ID in 15425
the array
healthNo int 16 Stores employee’s Health 14525
Surcharge ID in the array
insuranceValue int 4 Stores employee’s NIS Deduction 11
in the array
payeValue int 4 Stores employee’s PAYE 10
Deduction in the array
healthValue int 4 Stores employee’s Health 5
Surcharge Deduction in the array
grossSalary int 4 Stores employee’s Gross Salary 1550
value (before deduction of taxes)
in the array
netSalary int 4 Stores employee’s Net Salary 1524
value (after deduction of taxes) in
the array
Pay Date Structure Array
PayDate date int 10 Stores the date in which the 11/11/2022
(2+2+4+ employee was paid in the format
3) DD/MM/YYYY, with the day,
month & year separated by
slashes
day int 2 Stores the day in which the 11
employee was paid
month int 2 Stores the month in which the 11
employee was paid
year int 4 Stores the year in which the 2022
employee was paid
Functional Testing
Add Employee Function:
Test 1: Adds Employee’s details to the employee array structure, with user-defined criteria:
Display All Employees:
Test 2: Displays all of the employee which were added to the system and currently stored in the
program
Sort Employees by Pay Value:
Test 2: Sorts all of the employees who have been added to the system accordingly to their net
salary value in descending order by the use of a bubble sort.
Before:
After:
Export Data to External File:
Test 3: This function takes all of the data entered by the user for the employees' records and
'sends or 'exports them to a .txt file named "Employee_Database.txt"
Before:
After:
User Documentation
1. From the main menu, type the number ‘1’ and then press ‘enter’
- Section 1: Salary Date
2. Enter the Employee’s pay date in the format DD/MM/YYYY, followed by clicking
‘enter’
- Section 2: Name, Time Worked & Pay Rate
3. Enter the Employee’s first name, followed by clicking ‘enter’
4. Enter the Employee’s last name, followed by clicking ‘enter’
5. Enter the Employee’s hours worked, followed by clicking ‘enter’
6. Enter the Employee’s days worked, followed by clicking ‘enter’
7. Enter the Employee’s pay rate, followed by clicking ‘enter’
- Section 3: Tax Identification Numbers
8. Enter the Employee’s National Insurance ID, followed by clicking ‘enter’
9. Enter the Employee’s Pay As You Earn ID, followed by clicking ‘enter’
10. Enter the Employee’s Health Surcharge ID, followed by clicking ‘enter’
- Section 4: Tax Deductions
11. Review the tax deduction values and if false, amend the values:
12. Enter the Employee’s updated National Insurance Deduction Value followed by clicking
‘enter’
13. Enter the Employee’s updated Pay As You Earn Deduction, followed by clicking ‘enter’
14. Enter the Employee’s updated Health Surcharge Deduction, followed by clicking ‘enter’
How to Display all Employees’ records which are stored in the array: