You are on page 1of 72

Higher Nationals

Internal verification of assessment decisions – BTEC (RQF)


INTERNAL VERIFICATION – ASSESSMENT DECISIONS

Programme title Higher National Diploma in Computing

Miss.Irani
Assessor Internal Verifier
Unit 01 - Programming
Unit(s)

Assignment title
Mohamed Ruzan
Student’s name
List which assessment criteria Pass Merit Distinction
the Assessor has awarded.

INTERNAL VERIFIER CHECKLIST

Do the assessment criteria awarded match


those shown in the assignment brief? Y/N

Is the Pass/Merit/Distinction grade awarded


justified by the assessor’s comments on the Y/N
student work?
Has the work been assessed
Y/N
accurately?
Is the feedback to the student:
Give details:
• Constructive?
• Linked to relevant assessment criteria? Y/N
• Identifying opportunities for Y/N
improved performance? Y/N
• Agreeing actions? Y/N
Does the assessment decision need
Y/N
amending?

Assessor signature Date

Internal Verifier signature Date


Programme Leader signature (if required)
Date

Mohamed Ruzan Unit 01 Programming 1


Confirm action completed
Remedial action taken

Give details:

Assessor signature Date

Internal Verifier
Date
signature
Programme Leader
Date
signature (if required)

Mohamed Ruzan Unit 01 Programming 2


Higher Nationals - Summative Assignment Feedback Form
Student Name/ID Mohamed Ruzan / KAN00130309
Unit Title Unit 01 - Programming
Assignment Number 1 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.

Pass, Merit & Distinction Descripts P1 M1 D1

LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a
Integrated Development Environment (IDE).

Pass, Merit & Distinction Descripts P2 M2 D2

LO3. Implement basic algorithms in code using an IDE.

Pass, Merit & Distinction Descripts P3 M3 D3

LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4

Grade: Assessor Signature: Date:


Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

Signature & Date:

* 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

Mohamed Ruzan Unit 01 Programming 3


Formative Feedback: Assessor to Student

Action Plan

Summative feedback

Feedback: Student to Assessor

Assessor Date
signature
E161001@esoft.academy
Student Date
signature

Mohamed Ruzan Unit 01 Programming 4


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.

Mohamed Ruzan Unit 01 Programming 5


5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each
page.

Word Processing Rules

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.

1. I know that plagiarism is a punishable offence because it constitutes theft.

Mohamed Ruzan Unit 01 Programming 6


2. I understand the plagiarism and copying policy of the Edexcel UK.
3. I know what the consequences will be if I plagiaries or copy another’s work in any of
the assignments for this program.
4. I declare therefore that all work presented by me for every aspects of my program,
will be my own, and where I have made use of another’s work, I will attribute the
source in the correct way.
5. I acknowledge that the attachment of this document signed or not, constitutes a
binding agreement between myself and Edexcel UK.
6. I understand that my assignment will not be considered as submitted if this
document is not attached to the attached.

Student’s Signature: Date:


(Provide E-mail ID) (Provide Submission Date)

Mohamed Ruzan Unit 01 Programming 7


Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number

Unit Number and Title Unit 01: Programming

Academic Year 2021/22

Unit Tutor

Assignment Title Design &Implement a GUI based system using a suitable


Integrated Development Environment

Issue Date

Submission Date

IV Name & Date

Submission Format

This submission will have 3 components

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)

2. Implemented System (Software)


The student should submit a GUI based system developed using an IDE. The system should connect with a
backend database and should have at least 5 different forms and suitable functionality including insert,
edit and delete of main entities and transaction processing.

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.

Mohamed Ruzan Unit 01 Programming 8


LO2. Explain the characteristics of procedural, object-orientated and event-driven
programming, conduct an analysis of a suitable Integrated Development
Environment (IDE).

LO3. Implement basic algorithms in code using an IDE.

LO4. Determine the debugging process and explain the importance of a coding
standard

Mohamed Ruzan Unit 01 Programming 9


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, ……..
In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence
relation.
Fn = F n-1 + F n-2

B. Factorial of a non-negative integer, is multiplication of all integers smaller than or equal


to n. For example, factorial of 6 is 6*5*4*3*2*1 which is 720.
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.

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 Explain 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). you also need to
critically evaluate the code samples that you have given above in relation to their
structure and the unique characteristics.

Activity 3 and Activity 4 are based on the following Scenario.

Ayubo Drive is the transport arm of Ayubo Leisure (Pvt) Ltd, an emerging travel & tour

Mohamed Ruzan Unit 01 Programming 10


company in Sri Lanka. It owns a fleet of vehicles ranging from cars, SUVs to vans.

The vehicles that it owns are hired or rented with or without a driver. The tariffs are based on
the vehicle type. Some of the vehicle types that it operates are, small car, sedan car, SVUs, Jeep
(WD), 7-seater van and Commuter van. New vehicle types are to be added in the future.

Vehicle rent and hire options are described below.

1. Rent (With or without driver) – For each type of vehicle rates are given per day, per week
and per month. Rate for a driver also given per day. Depending on the rent period the total
rent amount needs to be calculated. For example: if a vehicle is rented for 10 days with a
driver, total amount to be calculated as follows:

Total rent = weeklyRent x 1 + dailyRent x 3 + dailyDriverCost x 10

2. Hire (with driver only) – These are based on packages such as airport drop, airport pickup,
100km per day package, 200km per day package etc. Standard rates are defined for a
package type of a vehicle typeif that is applicable for that type of vehicle.For each package
maximum km limit and maximum number of hours arealso defined. Extra km rate is also
defined which is applicable if they run beyond the allocated km limit for the tour. For day
tours if they exceed max hour limit,a waiting charge is applicable for extra hours. Driver
overnight rate and vehicle night park rate also defined which is applicable for each night
when the vehicle is hired for 2 or more days.

Activity 3

Function 1: Rent calculation.


Return the total rent_value when vehicle_no, rented_date, return_date, with_driver
parameters are sent in. with_driver parameter is set to true or false depending whether the
vehicle is rented with or without driver.

Function 2: Day tour - hire calculation.


Calculate total hire_value when vehicle_no, package_type, start_time, end_time,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
waiting_charge and extra_km_charge as output parameters.

Function 3: Long tour - hire calculation.


Calculate total hire_value when vehicle_no, package_type, start_date, end_date,
start_km_reading, end_km_reading parameters are sent in. Should return base_hire_charge,
overnight_stay_charge and extra_km_charge as output parameters.

Write suable algorithms for vehicle tariff calculation for rents and hires. Ideally 3
functions should be developed for this purpose as above. Use the visual studio IDE
(using C#.net) to Implement the above algorithms and design the suitable database
structure for keeping the tariffs for vehicle types and different packages which must be

Mohamed Ruzan Unit 01 Programming 11


used for implementing the above functions.

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

4.1 Design and build a small system to calculate vehicle hire amounts and record them in a
database for customer billing and management reporting forAyubo drive. This includes the
completing the database design started in 3.2 and implementing one or more GUIs for
vehicle, vehicle type, and package add/edit/delete functions. It essentially requires an
interface for hire calculation and recording function described above. Generating customer
reports and customer invoices are not required for this course work.

4.2 Explain 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.

4.3 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.

Mohamed Ruzan Unit 01 Programming 12


Mohamed Ruzan Unit 01 Programming 13
Grading Rubric

Grading Criteria Achieved Feedback

LO1 Define basic algorithms to carry out an operation


and outline the process of programming an
application.

P1Provide a definition of what an algorithm is and outline


the process in building an application.

M1Determine the steps taken from writing code to


execution.

D1 Evaluate the implementation of an algorithm in a suitable


language. Evaluate the relationship between the written
algorithm and the code variant

LO2 Explain the characteristics of procedural,


objectorientated and event-driven programming,
conduct an analysis of a suitable Integrated
Development Environment (IDE)

Mohamed Ruzan Unit 01 Programming 14


P2Give explanations of what procedural, objectorientated,
and eventdriven paradigms are; their characteristics and the
relationship between them.

M2 Compare and contrast the procedural, object


orientated and event driven paradigms used in given
source code of an application

D2Critically evaluate the source code of an application which


implements the programming paradigms, in terms of the
code structure and characteristics.

LO3Implement basic algorithms in code using an IDE.

P3Write a program that implements an algorithm using an


IDE.

M3Use the IDE to manage the development process of the


program.

D3Evaluate the use of an IDE for development of


applications contrasted with not using an IDE.

Mohamed Ruzan Unit 01 Programming 15


LO4 Determine the debugging process and explain
the importance of a coding standard

P4Explain the debugging process and explain the debugging


facilities available in the IDE.

P5Outline the coding standard you have used in your code.

M4Evaluate how the debugging process can be used to


help develop more secure, robust applications.

D4 Critically evaluate why a coding standard is necessary in


a team as well as for the individual.

Mohamed Ruzan Unit 01 Programming 16


Contents
Activity 1................................................................................................................................... 20
What is an Algorithms? ............................................................................................................ 20
Characteristics of an Algorithm............................................................................................ 20
The Programming Process ................................................................................................... 21
Flowchart.................................................................................................................................. 22
Advantages of flowchart ...................................................................................................... 23
Disadvantages of flowchart.................................................................................................. 23
Pseudo code ............................................................................................................................. 25
Structured Programming ......................................................................................................... 26
The Fibonacci series ................................................................................................................. 26
Example of Fibonacci sequence ........................................................................................... 26
Pseudocode for Fibonacci series .............................................................................................. 27
Dry run for Fibonacci series ..................................................................................................... 28
Python code for Fibonacci series ............................................................................................. 28
Output .................................................................................................................................. 29
Factorial series ......................................................................................................................... 29
Pseudocode for factorial series................................................................................................ 29
Dry run for Factorial series ....................................................................................................... 30
Python code for Factorial ......................................................................................................... 31
Output Positive ........................................................................................................................ 31
Big-O Notation.......................................................................................................................... 32
Algorithm efficiency analysis using Big-O Notation ................................................................. 32
Explaining Fibonacci sequence using Big-O notation. ............................................................. 32
Activity 2................................................................................................................................... 34
Programming paradigm ........................................................................................................... 34
Procedural programming ......................................................................................................... 35
Characteristics of Procedural Programming ............................................................................ 35
Examples for procedural languages ......................................................................................... 35
Snippet for procedural programming paradigm ...................................................................... 36
Object Oriented Programming................................................................................................. 37
Main characteristics of Object-Oriented Programming paradigm .......................................... 37
Snippet for Object Oriented Programming .............................................................................. 38
Event-Driven Programming...................................................................................................... 39
Characteristics of Event-Driven Programming......................................................................... 40
Snippets for Event-Driven Programming paradigm ................................................................. 41
Critical evaluation between code samples .............................................................................. 41
Activity 3................................................................................................................................... 43
Basic Algorithms in code using and IDE ................................................................................... 43
Rent calculation.................................................................................................................... 43
Day tour calculation ............................................................................................................. 43
Long tour hire calculations ................................................................................................... 44
Consoles code for the algorithm .............................................................................................. 45
Rent calculation.................................................................................................................... 45
Day tour calculations............................................................................................................ 46

Mohamed Ruzan Unit 01 Programming 17


Output for day tour calculation ........................................................................................... 47
Long tour calculation............................................................................................................ 48
Output for long tour calculation .......................................................................................... 49
Creating database using SQL .................................................................................................... 50
Evidences.............................................................................................................................. 50
Create Database ............................................................................................................... 50
Create tables .................................................................................................................... 50
Package table ................................................................................................................... 51
Visual Studio IDE ...................................................................................................................... 52
The evolution of Visual Studio ............................................................................................. 52
Features of IDE ..................................................................................................................... 53
Disadvantages I would have encountered without IDE ....................................................... 54
Conclusion ................................................................................................................................ 54
Activity 4................................................................................................................................... 55
GUI for Ayubo........................................................................................................................... 55
Debugging ................................................................................................................................ 60
Tools and features for debugging in the Visual Studio IDE.................................................. 60
The following are some debugging tools I used for my program. ....................................... 62
Errors I faced and the Solutions I implemented .................................................................. 63
Conclusion ............................................................................................................................ 65
The Coding Standards .............................................................................................................. 66
Purpose of Having Coding Standards: .................................................................................. 66
Conclusion ............................................................................................................................ 69
Grant chart ............................................................................................................................... 71

Mohamed Ruzan Unit 01 Programming 18


Acknowledgement

In order to complete my assignment, I needed to enlist the assistance and counsel of some
highly respected individuals, for whom I am eternally grateful. As completing this
assignment gave me a lot of pleasure, I'd like to thank Ms. Irani, Course Instructor at Esoft
Metro Campus, for providing me with good guidelines for this assignment through
numerous consultations and feedback. I'd also like to thank everyone who has helped me
with this assignment, both directly and indirectly. Many people, particularly my batch
mates, provided insightful comments and suggestions on my system, which inspired me to
improve the quality of the assignment.

Thank You!!!

Mohamed Ruzan Unit 01 Programming 19


Activity 1

What is an Algorithms?
A process or set of rules to be followed in calculations or other problem-solving
operations is referred to as an algorithm. An intricate computer program can be
thought of as an algorithm. In mathematics and computer science and an algorithm
is a small procedure that solves a recurring problem. Algorithms are used in every
computerized device to reduce the time required to do things manually.

Characteristics of an Algorithm

• Input: An algorithm requires some input values. An algorithm can be given a


value other than 0 as input.
• Output: At the end of an algorithm, you will have one or more outcomes.
• Unambiguity: A perfect algorithm is defined as unambiguous, which means
that its instructions should be clear and straightforward.
• Finiteness: An algorithm must be finite. Finiteness in this context means that
the algorithm should have a limited number of instructions, i.e., the
instructions should be countable.
• Effectiveness: Because each instruction in an algorithm affects the overall
process, it should be adequate.
• Language independence: An algorithm must be language-independent, which
means that its instructions can be implemented in any language and produce
the same results.

(Upadhyay
, n.d.)

Mohamed Ruzan Unit 01 Programming 20


The Programming Process

A programmer must go through the seven steps of the program development process
following the steps to develop a computer program:

1. Define the program objectives

The programmer investigates the problem in this step. It is also


necessary to research the issue because it will assist the programmer in
deciding:

• Facts and figures required to create algorithm.


• How to design a program?
• The language in which the program works best.
• What is the desired output and in what format?

2. Design the program

An algorithm is a series of steps that must be completed before a


programmer can begin working on his program. A programmer creates
an algorithm to aid in the visualization of potential alternatives in a
program.

3. Write the code

After developing the algorithm, the program is written in a high-level


language. This procedure is known as coding.

4. Test execution

The process of running a program to look for flaws or problems is


known as test execution. It assists a programmer in verifying the logic
of the program. It also ensures that the program is error-free and
functional.

Mohamed Ruzan Unit 01 Programming 21


5. Debugging

Debugging is the process of identifying, locating and correcting errors


in software. It is accomplished by repeatedly running the software.

6. Final documentation

Flowchart

A flowchart is a diagram that depicts a process’s or workflow’s steps, sequences and


decisions. While there are many different types of flowcharts, the most basic form of
a process map is a basic flowchart. It is a powerful tool that can be used in multiple
fields for planning, visualizing, documenting and improving processes.

Flowchart symbols

• Flowline: The flowline shows the process’s direction by connecting two


blocks with one another.
• Termina or Terminator: The terminal or terminator represents the start or
end points of a flowchart process.
• Process: The process symbol is the most common component of a flowchart
and indicates a step in the process.
• Comment or Annotation: You can indicate additional information about a
step with a comment or annotation.
• Decision: This symbol represents a decision you or your team need to make to
get to the next step of the process. Typically, it’s a true or false decision or a
yes or no question that you need to answer.
• Input/Output: The input/output symbol represents the process of in- or
outputting external data.
• Display: This indicates a step that displays relevant information.

(Asana, n.d.)

Mohamed Ruzan Unit 01 Programming 22


Advantages of flowchart

• Easy to make
• Analysis becomes effective
• Debugging becomes possible
• Mistakes can be easily identified

Disadvantages of flowchart

• No man to computer communication


• Reproduction becomes a problem
• No scope for alteration or modification

Mohamed Ruzan Unit 01 Programming 23


Example:

Start

Get score

NO
0<=score<=
100

YES

YES
Score=>75
A

NO

Score=>65 YES
B

NO

YES
Score=>50
C

NO

Fail

Figure 1 flow chart


End

Mohamed Ruzan Unit 01 Programming 24


Pseudo code

Pseudo code is a term that is commonly used in programming and algorithm-based


fields. This methodology enables programmers to represent an algorithm’s
implementation.

This is simply an algorithm implementation in the form of simple English annotations


and informative text. Because it lacks the syntax of other programming languages, it
cannot be complied or interpreted on a computer.

Example of pseudo code

BEGIN
total = 0
grade_counter = 1
while grade_counter <= 10
input grade
total = total + grade
grade_counter = grade_counter + 1
class_avarage = total / 10
print class_avearge
END

Mohamed Ruzan Unit 01 Programming 25


Structured Programming

Structured programming is a programming paradigm that makes extensive use of the


structured control flow components of selection (if/ then/ else) and repetition (for
and while), block structures and subroutines to improve a computer program’s
clarity, quality and development time.
Ex: C++, C#, JAVA, etc.
Features of structured programming
Sequence – in computer programming, this is a set of instructions that follow on one
from other.
Selection – a decision within a computer program when the program decides to
move on based on the results of an event.
Iteration – the repletion of a block of statements within a computer program.

The Fibonacci series

The Fibonacci sequence is a series of number named after the Italian mathematician
Fibonacci. It’s just a string of numbers that starts with 0 and 1 and continues by
adding the two numbers before it.

Example of Fibonacci sequence

Find the Fibonacci number when n=5, using recursive relation.

Solution:

The formula to calculate the Fibonacci Sequence is: Fn = Fn-1+Fn-2

Take: F0=0 and F1=1

Using the formula, we get

F2 = F1+F0 = 1+0 = 1

F3 = F2+F1 = 1+1 = 2

Mohamed Ruzan Unit 01 Programming 26


F4 = F3+F2 = 2+1 = 3

F5 = F4+F3 = 3+2 = 5

Therefore, the Fibonacci number is 5. (Anon., n.d.)

Pseudocode for Fibonacci series

Function fib(n)

If n<=1 then:

Return n

Else

Return (fib(n-1) +fib(n-2))

End function

PROGRAME

Start

Input num

If returns<=0

Print (‘error enter positive numbers only’)

Else

Print (‘Fibonacci sequence)

For I in range(returns)

Var=fib recursion (i)

Print(var)

End

Mohamed Ruzan Unit 01 Programming 27


Dry run for Fibonacci series
num n n<=1 fib(n-1) + fib(n-2) output

3 3 F 0 0

2 F 1 1

1 1 1

Python code for Fibonacci series

Figure 2 python code for Fibonacci series

Mohamed Ruzan Unit 01 Programming 28


Output

Figure 3output

Factorial series

Finding the factorial of a number is a common requirement in data analysis and other
python-based mathematical analysis. For a positive integer, the factorial is always
fund by multiplying all integers from 1 to the given number. There are three ways to
find this, as shown below.

Pseudocode for factorial series

Print (“enter a number for calculating factorial”)

Function fact(num2)

If num2==0:

Return 1

Else:

Return num2*factorial(num2-1)

End function

Mohamed Ruzan Unit 01 Programming 29


Start

Input num

If num<0:

Print(‘=error..factorial does not exit’)

Else:

N=fact(num)

Print(n)

End

Dry run for Factorial series


num num2 n==1 num2*num2(num2-1) output

3 3 F 3* fact 2 6

2 F 2* fact 3

1 T 1* fact 0

Mohamed Ruzan Unit 01 Programming 30


Python code for Factorial

Figure 4 pythone code for factorial

Output Positive

Output Negative

Figure 5 output negative

Mohamed Ruzan Unit 01 Programming 31


Big-O Notation

Big O notation is a convenient way to express how quickly a function grows. It I


really useful, or even possible, to compute an exact result when studying an
algorithm’s time complexity T(n). typically, we are only concerned with how quickly
T (n) grows as function of the input size n.

Algorithm efficiency analysis using Big-O Notation

In analyzing an algorithm’s efficiency, independent of the programming language


used or computing device on which it’s run, it’s important to evaluate the number of
operational steps involved in the execution of the algorithm. By expressing the steps
in the form of an equation, we can then say that an algorithm’s efficiency is equal to
the most dominant part of that equation. (Ndemo, n.d.)

Explaining Fibonacci sequence using Big-O notation.

Python code:

def recur_fibo(n):

if n <= 1:

return n

else:

return(recur_fibo(n-1) + recur_fibo(n-2))

nterms = 10

if nterms <= 0:

Mohamed Ruzan Unit 01 Programming 32


print ("Plese enter a positive integer")

else:

print ("Fibonacci sequence:")

for i in range(nterms):

print(recur_fibo(i))

Model the time function for calculating Fib(n) as the sum of the time it takes to
calculate Fib(n-1) plus the time it takes to add the two together (O (1)). This assumes
that subsequent evaluations of the same Fib (n) require the same amount of time - that
is, there is no memorizing.

T (n<=1) = O (1)

T (n) = T (n-1) + T (n-2) + O (1)

The solution will be obtained by solving this recurrence relation (for example, using
generating functions).

Draw the recursion tree with depth n and intuitively determine that this function is
asymptotically O.(2n). Induction can be used to prove the hypothesis.

Base: n = 1 is obvious

Assume T (n-1) = O (2n-1), therefore

T (n) = T (n-1) + T (n-2) + O (1) which is equal to

T (n) = O (2n-1) + O (2n-2) + O (1) = O (2n)

An interesting fact about this function is that the T (n) is asymptotically the same as
the value of Fib (n) since both are defined as

Mohamed Ruzan Unit 01 Programming 33


F (n) = f (n-1) + f (n-2).

The recursion tree's leaves will always return one. Fib (n) is the sum of all values
returned by the recursive tree's leaves that are equal to the number of leaves. T (n)
equals Fib (n) x O because each leaf will take O (1) to the computer (1). As a result,
the Fibonacci sequence ((1.6n)) is the tight bound for this function. You can discover
this tight bond by using the generating functions I mentioned earlier.

Activity 2

Programming paradigm

Programming paradigms are different ways or styles in which a given program or


programming language can be organized. Each paradigm consists of certain
structures, features, and opinions about how common programming problems should
be tackled.

The question of why are there many different programming paradigms is similar to
why are there many programming languages. Certain paradigms are better suited for
certain types of problems, so it makes sense to use different paradigms for different
kinds of projects.

Also, the practices that make up each paradigm have developed through time. Thanks
to the advances both in software and hardware, different approaches have come up
that didn't exist before.

And last I think, there's human creativity. As a species, we just like creating things,
improving what others have built in the past, and adapting tools to our preference or
to what seems more efficient to us.

All this results in the fact that today we have many options to choose from when we
want to write and structure a given program. (Cocca, n.d.)

Mohamed Ruzan Unit 01 Programming 34


Procedural programming

Procedural programming is a derivation of imperative programming, adding to it the


feature of functions (also known as "procedures" or "subroutines").

In procedural programming, the user is encouraged to subdivide the program


execution into functions, as a way of improving modularity and organization.

Characteristics of Procedural Programming

• Top-down approaches are used in procedural programming.


• The program is divided into code blocks called functions, with each function
performing a specific task.
• Procedural programs represent real-world processes as 'procedures' that
operate on 'data.'
• Data and functions are separate entities.
• In a program, data flows freely.
• A program's logic is simple to understand.
• By calling another function, a function can gain access to the data of that
function.

Examples for procedural languages

To understand the example of procedural language we write a program for adding two
numbers in C. The option of two numbers in C language is playing out the math
activity of including them and printing their entirety on the screen. For instance, if the
information is 2, 3, the yield will be 5.

#include <iostream.h>

Int main () {

Mohamed Ruzan Unit 01 Programming 35


Int a;

Int b;

Int c;

printf (“enter the numbers for addition”);

scanf (“%d%d”, &a, &b);

c = a + b;

printf (“sum of the number are = %d\n”, c);

return 0;

} Output of the given program is: 5 (Anon., n.d.)

Examples:

Snippet for procedural programming paradigm

Ex 1:

Figure 6 pythone code for procedural


programming

Figure 7 output

Ex 2:

MohamedFigure
Ruzan8 pythne code for PP Unit 01 Programming 36
Figure 9 output

Object Oriented Programming

Object Oriented programming (OOP) is a programming paradigm that relies on the


concept of classes and objects. It is used to structure a software program into simple,
reusable pieces of code blueprints (usually called classes), which are used to create
individual instances of objects. There are many object-oriented programming
languages including JavaScript, C++, Python and JAVA. (Doherty, n.d.)

Main characteristics of Object-Oriented Programming paradigm

• Classes - You must first develop a class before you can generate objects. A
class is a template that specifies an object’s priorities and methods. Simply put
a class is a collection of items.
• Inheritance - Reusability is another name for inheritance. The practice of
passing on data, members, and methods from one class to another, as well as
the ability for a class to have its own, is known as inheritance. Simply we can
also state that inheritance is the facility that allows for code reuse. It is one of
the co characteristics of OOP.
• Encapsulation- Encapsulation is the process of combining data and procedures
into a single entity.
• Data Abstraction- Data abstraction, said simply, is data hiding. The method of
displaying the crucial feature without knowing the context is known as data

Mohamed Ruzan Unit 01 Programming 37


abstraction. We can shield the user from useless info and just display what is
essential.
• Polymorphism- Polymorphism is the representation of a single form over
numerous forms. “Polymorphism enables the definition of a single interface
with numerous implementations.” (Doherty, n.d.)

Snippet for Object Oriented Programming


Example:

Figure 11 output

Figure 10snippet for OOP

Class:

Figure 12 class

Objective:

Mohamed Ruzan Unit 01 Programming 38


Figure 13 object 1

Figure 14 object 2

In addition to being objects, methods can also relate to a class's function. Below are
several methods.

Figure 15 class function

Figure 16 class function 1

Event-Driven Programming

Event-driven programming is a computer programming paradigm where control flow


of the program is determined by the occurrence of events. These events are monitored
by code known as an event listener. If it detects that an assigned event has occurred, it

Mohamed Ruzan Unit 01 Programming 39


runs an event handler (a callback function or method that's triggered when the event
occurs).

In theory, all programming languages support the event-driven style of programming,


although some language features, such as closures, make it easier to implement. Other
programming environments, such as Adobe flash, are specifically tailored for
triggering program code by events. (computer hope, n.d.)

Characteristics of Event-Driven Programming

• Service oriented - Service oriented is a key feature in event-driven


programming that is used to write programs for services and it does not slow
down the computer because service oriented only consumes a small portion of
the computer processing power and usually services run in the background of
the operating system.
• Time Driven - Time driven is a paradigm in event driven programming that
refers to code that executes on a time trigger. Windows Update is a time
driven example, where the user may specify when to check for updates or
when to download them.
• Trigger Functions - In event-driven programming, trigger functions are a
function that determines what code to run when a given event occurs.
• Events- Events such as mouse, keyboard, and user interface must be triggered
by a program to occur, which requires interaction from the user with a
program object.
• Event Handlers- When a specific event is triggered, an event handler is a sort
of function or method that performs a specific action.

Mohamed Ruzan Unit 01 Programming 40


Snippets for Event-Driven Programming paradigm

Example:

Figure 17 snippets for E-DP

Turtle must first be imported. It has functions and methods

Figure 18 turtle func

Critical evaluation between code samples


The scripts make it simple to understand the various features of procedural,
event-driven, and OOP programming types. Because it is simple to understand, OOP
is faster than other programming languages, easier to learn, and applicable to a wide
range of applications on the other hand, is difficult to master. Furthermore, when
compared to the other two types of data, it necessitates more storage space.
Procedural programming is one of the most basic types of computer programming.
Any programming language that includes debugging features allows us to quickly

Mohamed Ruzan Unit 01 Programming 41


and easily fix errors and flaws. The examples show that all of the scripts adhere to
important coding conventions such as indentation, style, formatting, and others.

Mohamed Ruzan Unit 01 Programming 42


Activity 3

Basic Algorithms in code using and IDE

Rent calculation

Figure 19 rent calculation

Day tour calculation

Figure 20 day tour calculation

Mohamed Ruzan Unit 01 Programming 43


Long tour hire calculations

Figure 21 long tour calculation

Mohamed Ruzan Unit 01 Programming 44


Consoles code for the algorithm

Rent calculation

Figure 22 rent calculation 2


Figure 23 rent calculation

Mohamed Ruzan Unit 01 Programming 45


Day tour calculations

Mohamed Ruzan Unit 01 Programming 46


Output for day tour calculation

Figure 24 output day tour calculation

Mohamed Ruzan Unit 01 Programming 47


Long tour calculation

Figure 25 long tour calculation

Figure 26 long tour calculation 2

Mohamed Ruzan Unit 01 Programming 48


Figure 27 long tour calculation 3

Output for long tour calculation

Figure 28 output for long tour calculation

Mohamed Ruzan Unit 01 Programming 49


Creating database using SQL

Evidences

Create Database

Figure 29 create database

Create tables

Mohamed Ruzan Unit 01 Programming 50


Figure 30 create tables
Package table

Figure 31 package table

Figure 32 package table 2

Mohamed Ruzan Unit 01 Programming 51


Visual Studio IDE

Visual Studio is an Integrated Development Environment (IDE) developed by


Microsoft to develop GUI (Graphical User Interface), console, Web applications,
web apps, mobile apps, cloud, and web services, etc. With the help of this IDE, you
can create managed code as well as native code. It uses the various platforms of
Microsoft software development software like Windows store, Microsoft Silverlight,
and Windows API, etc. It is not a language-specific IDE as you can use this to write
code in C#, C++, VB (Visual Basic), Python, JavaScript, and many more languages.
It provides support for 36 different programming languages. It is available for
Windows as well as for macOS. (Anshul_Agarwal, n.d.)

The evolution of Visual Studio

The launch event and general release of Microsoft Visual Studio 2012 is imminent. I
keep getting email messages from my international .NET Association (INETA)
brethren about hosting an upcoming Visual Studio 2012 community launch event,
which suggests that the news will be public by the time you read this. Other than
Visual Studio, is there any other software that developers automatically upgrade to
without even questioning? Is there any other piece of software that you find you need
to get your hands on as much as this one?

As developers, we do love our tools. And there's no tool that's more important for
building software on the Microsoft platform than Visual Studio. Many developers
aren't the crazy type like me that would attempt to build production software on
prerelease tools. But I'm expecting that the majority of developers will switch to the
latest and greatest version when Visual Studio ships for production.

Interestingly enough, the first and last time I stood on stage next to Bill Gates was
when he was presenting a demo for the Visual Studio .NET 2003 launch event in
2003. My, how time has flown. Visual Studio has been on a new-version shipping
cadence of about every two years since then, as Table 1 shows, so we're right on track
for a fall release. (Huckaby, n.d.)

Mohamed Ruzan Unit 01 Programming 52


Features of IDE
Integrated Development Environment (IDE): The very first thing to choose is
obviously the IDE. It will be based on your coding platform and it should facilitate
you with all the common and extra features. And what are the features? Features can
be of your interest but also includes the following for sure;

1. Project: You should be able to create projects and open a single project in a
single window or multiple (better if in multiple windows, otherwise things go
a little slow). In this way you will be able to have all you project files listed
right beside your coding script just like file and folder browser.
2. Coding suggestion: While coding in a project which is so huge and you are
working on it for long time, it is obvious that you will forget not only language
specific methods and class names, but also your own variables, constants,
classes and method names. So, the good IDE must suggest you these whenever
you are typing.
3. Lite weight and fast: I understand, to provide you the previously mentioned
features an IDE will be working always and will keeping a lot of data in the
RAM. So, your IDE will become a little less responsive while opened for a
very long time. But still, if you have a multiple number of choices than pick
the one that takes less RAM.
4. Sub-Version: If your work in an environment that uses SVN then your IDE
should also. You should be able to commit and update directly from your IDE
and also the IDE should highlight files that has been changed and needs to be
committed.
5. Syntax Errors: I believe, this is important than coding suggestion. While
coding scripts, in early stages, missing semicolon at the end of a statement is
very common. A good IDE must highlight this and another like

➢ Missing function’s required arguments


➢ Invalid method calling through an object
➢ Use of undefined and unused variables
➢ Missing braces etc.

Mohamed Ruzan Unit 01 Programming 53


6. FTP facilities: If your work goes to a server in a regular interval or it is
directly connected to a clone at a server then your IDE should also facilitate
you with FTP connectivity feature so that you can always find out the files you
have changed and needs to be uploaded to the server. In this way, you won’t
have to worry about which files to upload and then browsing and uploading
them one by one, manually. Rather the IDE will take care of everything.
(Chakrabarty, n.d.)

Disadvantages I would have encountered without IDE

▪ The codes cannot be modified to meet my requirements


▪ Running the code would be difficult. Because of its drag-and-drop
functionality and simple interface, which are typical of a specific language.
▪ Designing interfaces would be difficult.
▪ There will be issues when using from applications because there will be no
way to use appropriate control names.
▪ It will take more time and effort to code the software since everything must be
done manually.
▪ It will be impossible to test and debug the designed system. Despite its
development, the application will contain numerous errors. The software will
not run without and IDE because we need a debugging tool to find errors.

Conclusion

Without an IDE, programmers will face numerous challenges because these tools,
which include a source code editor, complier, interpreter and debugger make it
easier to create software. As a results, IDE must be used for such a program to be
efficient and effective.

Mohamed Ruzan Unit 01 Programming 54


Activity 4

GUI for Ayubo

Figure 33 menu form

Mohamed Ruzan Unit 01 Programming 55


Figure 34 vehicle rent

Mohamed Ruzan Unit 01 Programming 56


Figure 35 package details

Mohamed Ruzan Unit 01 Programming 57


Figure 36 vehicle rent

Figure 37 day hire

Mohamed Ruzan Unit 01 Programming 58


Figure 38 long hire

Mohamed Ruzan Unit 01 Programming 59


Debugging

Debugging is the process of locating and removing coding mistakes in computer


programs. In information technology and engineering, the word 'bug' is a synonym for
the word 'error.' The goal of debugging is to identify and correct an error's root cause.

Debugging plays an important role in the software development process and


ironically, testing to determine and eliminating the presence of bugs can take just as
much time as writing code. The debugging process itself consists of identify the cause
of an error and fixing it. During the debugging process, which can be carried out
manually or automated through software debugging tools, engineers will look for:

• Syntax errors
• Typos
• Errors in logic
• Implementation errors (Anon., n.d.)

Tools and features for debugging in the Visual Studio IDE

Condition Breakpoint: By making it possible to locate the fault, this helps to stop the
recurrence.

Figure 39 condition breakpoint

Mohamed Ruzan Unit 01 Programming 60


Breakpoints: Breakpoints make it simpler to picture the program's step-by-step
execution.
This enables temporary code halting at particular locations.

Figure 40breakpoints

Execution Point: These indicate the line on which the execution is occurring.

Figure 41 execution point

• Controlled Code Execution: Breakpoints can be used to control executions.

1 2 3

1. Step Into- This allows you to call the function and watch the code as it runs.

2. Step Over- It is used to advance to the next line while the code is running.

3. Step Out- This is used to exit the function rather than running the function line
by line, which advances to the next statement.

Mohamed Ruzan Unit 01 Programming 61


o Edit and Continue: This is used to modify the code while debugging.
If it detects errors, it can help you to pause the program while you edit the
code, and then you can resume debugging by clicking the continue icon.

Figure 42 edit & continue

The following are some debugging tools I used for my program.

Error list: This aided me in identifying flaws in the program and determining where
it went wrong. According to the error message below, a ";" is therefore expected.

Figure 43 error list

As a result, I was able to overcome the problem as seen below by inserting a


colon.

Mohamed Ruzan Unit 01 Programming 62


Errors I faced and the Solutions I implemented

Problem 1

Figure 44 problem 1
The above error occurs due the single quotation inserted at code.

Figure 45 problem solve

At the end of the code, I had to remove the single quotation.

Mohamed Ruzan Unit 01 Programming 63


Problem 2

Figure 46 problem 2

The above error occurred due to spelling mistakes, and it was corrected from
“WriteeLine” to “WriteLine”.

Figure 47 problem solve 2

After the error I had to corrected the correct word.

Mohamed Ruzan Unit 01 Programming 64


Conclusion

Debugging tools, in my opinion, are essential when programming a program


because they have numerous functions for detecting errors and faults. furthermore,
improving software is a relatively simple and effective process. It saves time and
energy. So, by using these debugging tools, I ensured the security of my application.
It also helped me develop the program more efficiently.

Mohamed Ruzan Unit 01 Programming 65


The Coding Standards

Different modules specified in the design document are coded in the Coding phase
according to the module specification. The main goal of the coding phase is to code
from the design document prepared after the design phase through a high-level
language and then to unit test this code.

Good software development organizations want their programmers to maintain to


some well-defined and standard style of coding called coding standards. They usually
make their own coding standards and guidelines depending on what suits their
organization best and based on the types of software they develop. It is very important
for the programmers to maintain the coding standards otherwise the code will be
rejected during code review. (Anon., SAYAN KUMAR PAL)

Purpose of Having Coding Standards:

• A coding standard gives a uniform appearance to the codes written by


different engineers.
• It improves readability, and maintainability of the code and it reduces
complexity also.
• It helps in code reuse and helps to detect error easily.
• It promotes sound programming practices and increases efficiency of the
programmers.

Some of the coding standards are given below:

Mohamed Ruzan Unit 01 Programming 66


1. Limited use of globals:
These rules tell about which types of data that can be declared global and the
data that can’t be.

2. Standard headers for different modules:


For better understanding and maintenance of the code, the header of different
modules should follow some standard format and information. The header
format must contain below things that is being used in various companies:

• Name of the module


• Date of module creation
• Author of the module
• Modification history
• Synopsis of the module about what the module does
• Different functions supported in the module along with their input output
parameters
• Global variables accessed or modified by the module

3. Naming conventions for local variables, global variables, constants and


functions:
Some of the naming conventions are given below:

• Meaningful and understandable variables name helps anyone to understand the


reason of using it.
• Local variables should be named using camel case lettering starting with small
letter (e.g. localData) whereas Global variables names should start with a
capital letter (e.g. GlobalData). Constant names should be formed using
capital letters only (e.g. CONSDATA).
• It is better to avoid the use of digits in variable names.

Mohamed Ruzan Unit 01 Programming 67


• The names of the function should be written in camel case starting with small
letters.
• The name of the function must describe the reason of using the function
clearly and briefly.

4. Indentation:
Proper indentation is very important to increase the readability of the code.
For making the code readable, programmers should use White spaces
properly. Some of the spacing conventions are given below:

• There must be a space after giving a comma between two function arguments.
• Each nested block should be properly indented and spaced.
• Proper Indentation should be there at the beginning and at the end of each
block in the program.
• All braces should start from a new line and the code following the end of
braces also start from a new line.

5. Error return values and exception handling conventions:


All functions that encountering an error condition should either return a 0 or 1
for simplifying the debugging.

On the other hand, Coding guidelines give some general suggestions regarding the
coding style that to be followed for the betterment of understandability and readability
of the code. Some of the coding guidelines are given below :

6. Code should be well documented:


The code should be properly commented for understanding easily. Comments
regarding the statements increase the understandability of the code.

7. Length of functions should not be very large:


Lengthy functions are very difficult to understand. That’s why functions
should be small enough to carry out small work and lengthy functions should
be broken into small ones for completing small tasks.

Mohamed Ruzan Unit 01 Programming 68


8. Try not to use GOTO statement:
GOTO statement makes the program unstructured, thus it reduces the
understandability of the program and also debugging becomes difficult
(Anon., SAYAN KUMAR PAL)

Conclusion

Although coding standards have drawbacks, they are necessary when developing a
system. It has served as the system’s foundation. It can be used with ease if properly
maintained. It has more advantages than disadvantages. Coding standards must be
used for such a system to be productive and functional.

Mohamed Ruzan Unit 01 Programming 69


Mohamed Ruzan Unit 01 Programming 70
Grant chart

Figure 48 grant chart

Mohamed Ruzan Unit 01 Programming 71


Mohamed Ruzan Unit 01 Programming 72

You might also like