programing Assigment
programing Assigment
Unit(s)
Assignment title
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.
Give details:
Programme Leader
signature (if required) Date
Higher Nationals - Summative Assignment Feedback Form
Student Name/ID
nit Title
Assignment Number Assessor
Date Received 1st
Submission Date submission
Date Received 2nd
Re-submission Date submission
Assessor Feedback:
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a su
Integrated Development Environment (IDE).
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4
* Please note that grade decisions are provisional. They are only confirmed once internal and external moderation has taken
place and grades decisions have been agreed at the assessment board.
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Assessor Date
signature
Student Date
signature
Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01
General Guidelines
1. A Cover page or title page – You should always attach a title page to your assignment.
Use previous page as your cover sheet and make sure all the details are accurately
filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject, Assignment
No, and Page Number on each page. This is useful if individual sheets become detached
for any reason.
5. Use word processing application spell check and grammar check function to help editing
your assignment.
Important Points:
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in the
body except for the before mentioned compulsory information will result in rejection of
your work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
5. You must take responsibility for managing your own time effectively.
6. If you are unable to hand in your assignment on time and have valid reasons such as
illness, you may apply (in writing) for an extension.
7. Failure to achieve at least PASS criteria will result in a REFERRAL grade .
8. Non-submission of work without valid reasons will lead to an automatic RE FERRAL. You
will then be asked to complete an alternative assignment.
9. If you use other people’s work or ideas in your assignment, reference them properly
using HARVARD referencing system to avoid plagiarism. You have to provide both in-
text citation and a reference list.
10. If you are proven to be guilty of plagiarism or any academic misconduct, your grade
could be reduced to A REFERRAL or at worst you could be expelled from the course
Student Declaration
I hereby, declare that I know what plagiarism entails, namely to use another’s work and to
present it as my own without attributing the sources in the correct way. I further understand
what it means to copy another’s work.
Academic Year
Unit Tutor
Issue Date
Submission Date
Submission Format
1. Written Report
This submission is in the form of an individual written report. This should be written in a concise, formal
business style using single spacing and font size 12. You are required to make use of headings, paragraphs
and subsections as appropriate, and all work must be supported with research and referenced using the
Harvard referencing system. Please also provide a bibliography using the Harvard referencing system. (The
recommended word count is 1,500–2,000 words for the report excluding annexures)
3. Presentation
With the submitted system student should do a presentation to demonstrate the system that was
developed. Time allocated is 10 to 15 min. Student may use 5 to 10 PowerPoint slides while doing the
presentation, but live demonstration of the system is required. Evaluator will also check the ability to
modify and debug the system using the IDE.
Unit Learning Outcomes:
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
LO4. Determine the debugging process and explain the importance of a coding
standard
Assignment Brief and Guidance:
Activity 1
A. The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
Fn = F n-1 + F n-2
n! = n * (n - 1) * …….. 1
Define what an algorithm is and outline the characteristics of a good algorithm. Write the
algorithms to display the Fibonacci series and the factorial value for a given number using
Pseudo code. Determine the steps involved in the process of writing and executing a
program and carry out an analysis of writing the code phase by discussing the potential
challenges faced.
Take a sample number and dry run the above two algorithms. Show the outputs at the end
of each iteration and the final output. Examine what Big-O notation is and explain its role in
evaluating efficiencies of algorithms. Write the Python program code for the above two
algorithms and critically evaluate their efficiencies using Big-O notation.
Activity 2
2.1 Compare and discuss what is meant by a Programming Paradigm and the main
characteristics of Procedural, Object oriented and Event-driven paradigms and the
relationships among them. Write small snippets of code as example for the above three
programming paradigms using a suitable programming language(s) and critically
evaluate the code samples that you have given above in relation to their structure and
the unique characteristics.
Grifindo Toys is a small-scale Toy building company which is located in United Kingdom
(UK) and currently they have 50 employees working at their headquarters. They are looking
for a simple payroll system to calculate the salaries of their employees and you are hired as a
freelance software developer to build their payroll system.
Specifications for the payroll system as follows,
Grifindo Toys Payroll System mainly contains five components and the specifications for the
components are follows,
1. Employee Component.
Admin should be able to register employee details to the system (including
monthly salary, overtime rates-hourly, allowances).
Admin should be able to update all employee details in the system (Update and
Delete including monthly salary, overtime rates-hourly, allowances).
Admin should be able to view individual employee details, view all employees
details, search employees.
2. Salary Component
Admin should be able to input the date range to calculate the salary. Salary cycle
begin date and the end date should be given to calculate the monthly salary.
Salary cycle begin date and end date will be defined in the settings component
and if the user enters something else the system should display an error message.
The admin should be able to enter the no of leaves an employee has taken with
number of absent days, no of holidays for the given date range. If an employee
has worked any overtime hours the admin should be able to enter that also when
calculating the Base pay value.
Base Pay need to calculate based on the following points,
No-pay-value = (Total_Salary/salary_cycle_date_range)
*No_of_absent_days
Base Pay need to calculate according to the below mentioned formula
All the calculated No-pay-value, Base-pay-value and Gross pay value should
record in the database under each employee for each month. This component
should generate reports such as monthly salary report for an employee, overall
salary summary for couple of months for an employee, No-pay-value, base-pay-
value, and gross pay value of all the employees for a given month range.
3. Settings Component
This component should allow the admin to change parameter values such as
i. Date Range for a salary cycle. Eg:- 30 days
ii. Salary cycle begin date
iii. Salary cycle end date
iv. No of leaves for an employee for a year.
Activity 3
Write the complete pseudocode for the salary component of the above system (report
generation is not needed). Use the visual studio IDE (using C#.net) to implement the
above three components. Ideally there should be three separate classes for the above
three components and the developer can decide the methods which need to include in
those classes. Design the suitable database structure for keeping the data of the above
system.
Analyze the features of an Integrated Development Environment (IDE) and explain how
those features help in application development. Evaluate the use of the Visual StudioIDE
for your application development contrasted with not using an IDE.
Activity 4
2.1 Design and build a small GUI system for the above scenario and it should be a complete
functional system with all the functions which has described in the above scenario with the
database structure which has designed in activity 3.
2.2 Examine debugging process and the features available in Visual studio IDE for debugging
your code more easily. Evaluate how you used the debugging process to develop more
secure, robust application with examples.
2.3 Explain and outline the coding standards you have used in your application development.
Critically evaluate why a coding standard is necessary for the team as well as for the
individual.
Contents
Activity 01.........................................................................................................................19
Algorithm......................................................................................................................19
Characteristics of a good algorithm..............................................................................19
Pseudo code for Fibonacci Series.................................................................................19
Pseudo code for Factorial.............................................................................................20
The process of building an application.........................................................................20
Challenges of Writing Code.......................................................................................... 21
Dry Run......................................................................................................................... 21
Big-O Notation..............................................................................................................23
Python Code................................................................................................................. 23
Efficiency Analysis.........................................................................................................24
Activity 2...........................................................................................................................25
programming paradigm................................................................................................25
Procedural Paradigm.................................................................................................... 25
Object-Oriented Paradigm............................................................................................25
Event-Driven Paradigm.................................................................................................26
Activity 3...........................................................................................................................28
Pseudocode for Salary Component..............................................................................28
Database Structure.......................................................................................................29
Features of an Integrated Development Environment (IDE)........................................31
Activity 4...........................................................................................................................32
4.1 GUI system using C# and Visual Studio...................................................................32
4.2 Debugging Process and Features in Visual Studio IDE:...........................................37
4.3 Coding Standards used...........................................................................................38
4.3.1 Importance of Coding Standards.........................................................................39
References
https://dictionary.cambridge.org/dictionary/english/algorithm
Characteristics of an Algorithm - Coding Ninjas
https://shiverware.com/app-development/7-steps-app-development.html
https://www.codegrip.tech/productivity/code-review-challenges-faced-by-
developers/
https://study.com/academy/lesson/dry-run-testing-in-software-development.html
https://www.freecodecamp.org/news/an-introduction-to-programming-
paradigms/
https://www.veracode.com/security/integrated-development-environment
Explain the debugging process and explain the debugging facilities available in
the IDE - Debugging: - Studocuhttps://www.browserstack.com/guide/coding-
standards-best-practices
https://blog.codacy.com/coding-standards
Activity 01
Algorithm
Correctness:
It should output the right result for all valid inputs.
Efficiency:
It should use the fewest resources (time, memory) to solve the problem.
Clarity:
It should be simple to understand and follow.
Finiteness:
The process should end after a finite number of steps.
Generality:
It should be adaptable to a diverse set of inputs within its problem domain.
Modularity:
It should be divided into smaller, more manageable components/modules.
Robustness:
It should handle invalid inputs gracefully and without crashing.
1. Problem understanding
Make sure you understand the problem statement and the requirements.
2. Algorithm Design
Design a step-by-step plan for solving the problem.
3. Coding
Translate the algorithm into code using a programming language.
4. Testing
Run the code with various inputs to check it produces the expected results.
5. Debugging
Locate and correct any faults or problems in the code.
6. Optimization
Refactor the code to increase its performance or readability if needed
7. Documentation
Document the code so that others can understand it and keep it for future
reference.
8. Deployment
Making the application available for use.
9. Maintenance
Updating and enhancing the application over time.
Dry Run
Let's take a sample number, say 5, for both Fibonacci and Factorial algorithms.
Fibonacci Series:
fibonacci(1) = 1
fibonacci(0) = 0
Substituting back:
fibonacci(2)=1+0=1
fibonacci(3)=1+1=2
fibonacci(4) 2+1=3
fibonacci(5) 3+2=5
So, fibonacci(5) = 5.
Factorial:
factorial(5) 5* factorial(4)
factorial(4) 4* factorial(3)
factorial(3) = 3* factorial(2)
factorial(2) = 2* factorial(1)
factorial(1) = 1
factorial(0) = 1
Substituting back:
factorial(1) = 1
factorial(2) = 2*1=2
Big-O Notation
Big-O notation is used to describe the upper bound of the time or space
complexity of an algorithm in terms of the input size. It helps in evaluating the
efficiency of algorithms by providing a measure of how the runtime or space
requirements grow as the input size increases.
Python Code
#Fibonacci Series
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-1)+fibonacci(n-2)
#Factorial
def factorial(n):
if n <= 1:
return 1
else:
return n factorial(n-1)
#Testing with sample number
sample number = 5
Efficiency Analysis
Fibonacci:
The time complexity of the Fibonacci algorithm using recursion is O(2^n), which grows
exponentially with the input size. This can be optimized to O(n) using dynamic
programming.
Factorial:
The time complexity of the factorial algorithm is O(n) as it involves n multiplications.
Activity 2
programming paradigm
A programming paradigm is a fundamental style or approach to programming that defines
the structure and elements of computer programs. It encompasses the principles, methods,
and concepts used in software development. Three common programming paradigms are:
procedural, object-oriented, and event-driven.
Procedural Paradigm
In the procedural paradigm, programs are structured around procedures or routines that
operate on data.
Characteristics:
Emphasis on procedures or functions.
Focus on step-by-step execution.
Data and procedures are separate.
Def factorial(n):
result = 1
for i in range(1, n + 1):
result *= i
return result
Evaluation:
Procedural code is simple understand and maintain, particularly for small to
medium-sized projects. However, as the project expands, it can become more
complex and difficult to manage, leading to issues like spaghetti code.
Object-Oriented Paradigm
Object-Oriented Programming organizes code around objects that contain data and
behavior.
Characteristics:
Encapsulation, inheritance, and polymorphism.
Objects interact through methods and messages.
Reusability and modularity.
Example Code (in Python)
class
FactorialCalculator:
def factorial (self, n):
if n == 0:
return 1
else:
return n *
self . factorial (n - 1)
Evaluation:
OOP promotes code organization, extensibility, and reusability through use of
classes and objects. It facilitates collaborative development and large-scale
software projects. However, designing effective class hierarchies and managing
relationships between objects can be challenging.
Event-Driven Paradigm
Event-driven programming responds to events triggered by user actions or system
events.
Characteristics:
Event handlers/callback functions.
Asynchronous programming model.
GUI applications often use this paradigm.
Example Code (in Python)
Import tkinter as tk.
def button_click():
print("Button was clicked!").
# Create a tkinter window
window = tk.Tk()
Evaluation:
Event-driven programming is suitable for developing interactive and responsive
applications, such as graphical user interfaces (GUIs) and web applications. It can
simplify complex event handling logic, but may lead to callback hell and hard-to-
follow program flow in certain cases.
In summary, each programming paradigm has its own strengths and weaknesses, and the
choice of paradigm depends on factors such as project requirements, team expertise, and
development goals. Procedural programming emphasizes step-by-step execution, OOP
focuses on modelling real-world entities, and event-driven programming enables
asynchronous and interactive behavior. These paradigms can be complementary, and
hybrid approaches are common in modern software development.
Activity 3
class SalaryComponent:
method calculateSalary (employee, startDate, endDate, leaves Taken, absentDays,
holidays, overtimeHours):
basePay =
calculateBasePay(employee, startDate, endDate, absentDays, overtimeHours)
noPayValue =
calculateNoPayValue(employee, startDate, endDate, absentDays)
grossPay =
calculateGross Pay(basePay, employee.government TaxRate, noPayValue)
return basePay, grossPay
method
calculateBasePay(employee, startDate, endDate, absentDays, overtime Hours):
salaryCycleDays = (endDate - startDate).days + 1
if (salaryCycleDays != 30):
# Assuming a standard 30-day cycle
noPayValue =
(employee.monthlySalary / 30) *
absentDays
basePay =
employee.monthlySalary + employee.allowances + (employee.overtimeRate *
overtimeHours) - noPayValue
else:
basePay =
employee.monthlySalary + employee.allowances + (employee.overtimeRate *
overtimeHours)
return basePay
method
calculateNoPayValue(employee, startDate, endDate, absentDays):
salaryCycleDays = (endDate - startDate).days + 1
if (salaryCycleDays != 30):
# Assuming a standard 30-day cycle
return
(employee.monthlySalary / 30) *
absentDays
else: return 0
method
calculateGrossPay(basePay, government Tax Rate, noPayValue):
grossPay = basePay - (noPayValue + basePay *
govermentTaxRate)
return grossPay
Database Structure
Employee Table:
Name
Monthly Salary
OvertimeRate
Allowances
Salary Table:
DateRange
NoOfLeaves
NoOfAbsentDays
NoOfHolidays
NoOfOvertime Hours
BasePay
NoPayValue
GrossPay
Settings Table:
SalaryCycleBeginDate
SalaryCycleEndDate
NoOfLeaves PerYear
GovernmentTaxRate
Features of an Integrated Development Environment (IDE)
Code editor:
Designed for writing and editing source code, these editors are distinguished
from text editors because work to either simplify or enhance the process of
writing and editing of code for developers
Compiler:
Compilers transform source code that is written in a human readable/writable
language in a form that computers can execute.
Debugger:
Debuggers are used during testing and can help developers debug their
application programs.
Build automation tools:
These can help automate developer tasks that are more common to save time.
Class browser:
Used to study and reference properties of an object-oriented class hierarchy.
Object browser:
Used to inspect objects instantiated in a running application program.
Class hierarchy diagram:
Allows developers to visualize the structure of object-oriented programming code
Activity 4
The Main form serves as the central hub for navigating the Grifindo Toys Payroll
System. It provides administrators with quick access to key functionalities by
presenting buttons for accessing different sections of the system. The buttons labeled
"Employee Management," "Salary Calculation," "Settings," and "Reports" allow
administrators to seamlessly transition between various modules of the payroll system.
Administrators can click on these buttons to perform tasks such as managing employee
details, calculating salaries, configuring system settings, and generating reports. The
Main Dashboard enhances user experience by offering a straightforward and intuitive
interface for accessing different features of the payroll system. It streamlines
navigation and facilitates efficient workflow management for administrators
overseeing payroll operations
Employee Management form
This form enables administrators to manage employee details within the Grifindo Toys
Payroll System. Administrators can register new employees, update existing employee
information, view individual employee details, view all employees' details, and search
for specific employees using the provided functionalities.
Salary Calculation Form
This form allows administrators to calculate salaries for employees based on specified
parameters such as the salary cycle duration, start and end dates, leaves taken, absent
days, holidays, and overtime hours. Administrators can input these parameters and
initiate the salary calculation process using the provided button.
Settings Form
The Settings Form allows administrators to configure various parameters related to the
payroll system. Administrators can specify the salary cycle duration, salary cycle begin
and end dates, and the number of leaves allowed for employees. These settings help
customize the payroll system according to the organization's requirements.
Reports Form
Explanation: This form facilitates the generation of different types of reports within the
Grifindo Toys Payroll System. Administrators can select the desired report type from a
dropdown list, input parameters such as employee ID and month, and then generate the
corresponding report. Report types may include monthly salary reports, overall salary
summaries, and other relevant reports for monitoring employee compensation and
performance.
4.2 Debugging Process and Features in Visual Studio IDE:
1. Breakpoints:
Usage: Set breakpoints at key points in the code where you suspect issues might arise,
such as before calculations or database operations.
Example: Set breakpoints in the salary calculation method to examine the values of
variables like monthly salary, overtime rates, and allowances during execution. This
helps in verifying if the inputs are correct and if the calculations are performed
accurately.
Usage: Navigate through the code execution step by step to understand its flow and
identify any anomalies.
Example: Use "Step Into" to dive into function calls and inspect their behavior. "Step
Over" allows bypassing function calls to focus on the main logic. "Step Out" helps in
quickly returning from function calls once their behavior has been examined
thoroughly.
3. Watch Windows:
4. Immediate Window:
Example: Use the Immediate Window to manually calculate gross pay based on the
provided formulas using current variable values. Compare the result with the
calculated gross pay in the code to identify discrepancies and pinpoint calculation
errors.
5. Exception Handling:
Usage: Catch and handle exceptions gracefully to prevent application crashes and
ensure robustness.
Example: Implement try-catch blocks around critical sections of the code, such as
database operations or file I/O. Log exceptions with detailed information to aid in
troubleshooting and resolving issues efficiently.
Usage: Detect potential vulnerabilities, code smells, and style violations to improve
code quality and security.
Example: Run static code analysis tools provided by Visual Studio to identify potential
security vulnerabilities, such as SQL injection or cross-site scripting, and address them
proactively.
By leveraging these debugging features effectively, developers can identify and rectify
issues early in the development process, leading to the creation of more secure and
robust applications like the Grifindo Toys Payroll System. Additionally, thorough testing
and validation of the application's functionalities during debugging ensure its reliability
and accuracy in handling sensitive payroll data.
4.3 Coding Standards used
Naming Conventions:
Descriptive and meaningful names are used for variables,
methods, and classes. Variables follow camelCase notation, while methods and
classes follow PascalCase. For example:
calculateBasePay
getMonthlySalary
SalaryComponent
Indentation:
Consistent indentation is maintained throughout the code,
enhancing readability and organization.
Commenting:
Clear and concise comments are included to explain complex
logic or sections of code, improving understanding for developers.
Error Handling:
Proper error handling and exception management are
implemented, ensuring the robustness of the application.
Modularization:
The code is structured into modular components, promoting
maintainability and reusability.
Consistency:
A consistent coding style is followed across the entire codebase,
facilitating collaboration and comprehension among developers.
Coding standards are crucial for both individual developers and teams for the following
reasons:
Readability and Maintainability:
Consistent coding standards improve code readability, making it easier to understand
and maintain by individuals and teams.
Collaboration:
Enforcing coding standards ensures uniformity across the codebase, facilitating
collaboration among team members.
Quality Assurance:
Adherence to coding standards helps in identifying potential issues early in the
development process, leading to higher code quality and fewer bugs.
Scalability:
Consistent coding standards enable scalability of the project as it grows, ensuring that
new additions or modifications align with existing code practices.
Code Reviews:
Coding standards serve as a guideline during code reviews, allowing reviewers to focus
on logic and functionality rather than style inconsistencies.
Grading Rubric