Uploaded by Godrick Naveen

HND(Programming assignment)

advertisement
Pearson Higher Nationals in
Computing
Unit 1: Programming Assignment 1
Godrick Naveen KAN/A-013536
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)
INTERNAL VERIFICATION – ASSESSMENT DECISIONS
Programme title
HND in Computing
Miss.Shifani Mohideen
Assessor
Internal
Verifier
Unit 1 – Programming
Unit(s)
Assignment title
Design & Implement a GUI based system using
a suitable Integrated Development
Environment
P.V.Godrick Naveen
Student’s name
List which assessment
criteria the Assessor has
awarded.
Pass
Merit
Distinction
INTERNAL VERIFIER CHECKLIST
Do the assessment criteria awarded match
those shown in the assignment brief?
Is the Pass/Merit/Distinction grade
awarded justified by the assessor’s
comments on the student work?
Has the work been assessed
accurately?
Y/N
Y/N
Y/N
Is the feedback to the student:
Give details:
•
•
Constructive?
•
Identifying
opportunities
for improved performance?
•
Agreeing actions?
Linked to relevant assessment
criteria?
Does the assessment decision need
amending?
Y/N
Y/N
Y/N
Y/N
Y/N
Assessor signature
Date
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 1
Internal Verifier signature
Date
Programme Leader signature (if required)
Date
Confirm action completed
Remedial action taken
Give details:
Assessor signature
Date
Internal Verifier
signature
Date
Programme Leader
signature (if required)
Date
Student Name/ID
KAN/A-013536
Unit Title
Unit 01: Programming
Assignment Number
1
Assessor
Submission Date
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Miss.Shifani Mohideen
Higher Nationals - Summative Assignment Feedback Form
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 2
Assessor Feedback:
LO1 Define basic algori thms to carry out an operation
and outline the process of programming an
application.
Pass, Merit & Distinction P1
Descripts
M1
D1
LO2 Explain the characteristics of procedural,
objectoriented and event-driven
programming, Integrated Development
Environment (IDE).
Pass, Merit & Distinction P2
D2
M2
Descripts
LO3 Implement basic al gorithms in code using an IDE.
Pass, Merit & Distinction P3
M3 Descripts
D3
LO4 Determine the deb ugging process and explain the
importance of a coding standard.
Pass, Merit & Distinction P4
Descripts
Grade:
P5
M4
D4
Assessor Signature:
Date:
Resubmission Feedback:
Grade:
Assessor Signature:
Date:
Internal Verifier’s Comments:
Signature & Date:
Assignment Feedback
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 3
Formative Feedback: Assessor to Student
Mention only the important points
Action Plan
Unnecessary points were removed
Summative feedback
Thank you for being supportive throughout the assignment.
Feedback: Student to
As
sessor
Assessor signature
Student signature
Date
Kana013536@esoft.academy
Date
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 4
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 form. I further understand
what it means to copy another’s work.
1. I know that plagiarism is a punishable offence because it constitutes
theft.
2. I understand the plagiarism and copying policy of Edexcel UK.
3. I know what the consequences will be if I plagiarise 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 aspect 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 Pearson, UK.
6. I understand that my assignment will not be considered as submitted if
this document is not attached to the assignment.
Kana013536@esoft.academy
Student’s Signature:
(Provide E-mail ID)
Date:
(Provide Submission Date)
Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number
Unit Number and Title
Unit 01: Programming
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 5
Academic Year
2020/21
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
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 6
This submission will have 3 components
1. Written Report
This submission should be 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.
provide in-text citations, reference list and a bibliography using the Harvard referencing system. (The
recommended word count is 2,00–25,00 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:
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 7
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 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
Contents
Activity 1
1.1 Algorithm .................................................................................................................
8
1.2 Linear Search ......................................................................................................... 10
Activity 2
2.1 Programming Paradigms ........................................................................................
16
2.2 Using the Procedural and Imperative Programming Paradigms in Python
Language. .....................................................................................................................
24
Activity 3
3.1 Algorithms for vehicle tariff calculation for rents and hires.................................. 34
3.2 Database structure for keeping the tariffs for vehicle types and different packages.
...................................................................................................................................... 37
3.3 Integrated Development Environment (IDE)......................................................... 46
Activity 4
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 8
4.1 The system to calculate vehicle hire amounts and record ...................................... 47
database record for customer billing and management reporting for Ayubo. ............. 47
4.2 What is debugging an application? ........................................................................ 53
4.3 Coding standards ....................................................................................................
56
Task 01
1.1 Algorithm
What is algorithm?
In computer programming, algorithms are often formed as functions. These functions
serve as small programs that can be referenced by a larger program. In many cases,
there are several ways to perform a specific operation within a software program. In
general term, An algorithm is defined as a set of instructions designed to perform a
specific task. Algorithms work via input and output. They take the input and apply each
step of the algorithm to that information to produce an output.
Characteristics of a good algorithm are,
•
Input and output should be defined accurately.
•
Each step in the algorithm should be clear and unmistakable.
•
Algorithms should be most effective among many different ways to solve a
problem.
•
An algorithm shouldn't contain computer code. Instead, the algorithm should be
written in such a way that it can be used in different programming languages.
Linear Search
In Linear Search Algorithm method we compare the elements of the array one-by-one
with the main element we are looking for in sequential order.The pseudo code for Linear
search would be like as given below ,
BEGIN
Index = -1
i=0
Found = False
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 9
WHILE i < length(numlist) AND NOT found
IF numlist[i] == numSought then
Index = i
Found = True Endif
i=i+1
Endwhile
Return Index
END
Binary Search
The Binary Search Algorithm can only be applied on sorted data and works by finding
the middle element in a list of information, some time recently choosing which side of
the information the required element is to be found within. The undesirable half of the
data is at that point rejected and the process is repeated until the required element is
found or until it is known that the required element doesn’t exist within the data.
The Time complexity of linear search is “O(n)”
The Pseudo code for Binary Search wouldlike as given below ,
BEGIN
Low = 0
High = a.length -1
WHILE Low <= High:
Mid = (Low + High) / 2
IF
a[Mid] == b:
Return Mid
Else if a[Mid] > b:
High
=
Mid
-1
Else:
Low = Mid + 1
Endif
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 10
Endwhile
Return “Not found”
END
1.2 Linear Search in Python Programming
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 11
Searching for Number “25” in the “array”
Iteration 1
5
0
10
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
Begins from the leftmost element of given array [] and one by one compare element
”a” with each element of array []
Iteration 2
5
10
0
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
It continues searching until either the element “25” is found or all the elements are
searched.
Iteration 3
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 12
5
0
10
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
Iteration 4
5
10
0
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
Iteration 4
5
10
0
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
Once ”a” equals with any of the element, returns the index value.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 13
Efficiency Analysis
Best Case
The search ends in success The element
with just one comparison.
being searched
may be found at the first
position.
Worst Case
The search terminates in
success
with
comparisons.
Average Case
“n”
The
element
being
searched may be existing
at the last position or not
exist in the array at all.
(n + 1) /2 comparison
Big-O Notation = O(n)
Binary Search in Python Programming
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 14
Searching for Number “30” in the “array”
Iteration
Low
High
Mid
Found
1
0
9
4
No
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 15
2
5
9
7
No
3
5
6
5
Yes
Iteration 1
5
0
10
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
10
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
10
1
15
2
20
3
25
4
30
5
35
6
40
7
45
8
50
9
Iteration 2
5
0
Iteration 3
5
0
Once ”a” equals with any of the element, returns the index value.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 16
Efficiency Analysis
Best Case
1 comparison
Item found in the 1st middle
element
Worst Case
Log 2 n comparison
Searching for non-existing
elements
Average Case
(Log 2 n + 1) /2
comparison
Average of above 2
Big-O Notation = O(Log 2 n)
Activity 2
2.1 Programming Paradigms
What is a programming paradigm ?
Programming paradigm is a method to deal with problems using some programming
language or additionally we can say it is a strategy to solve a problem using tools and
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 17
methods that are accessible to us following some methodology. There are lots for
programming language that are well-known but all of them need to follow some
approaches when they are implemented and this methodology is paradigms. There are
two main programming paradigms, an Imperative and a Declarative, and there are
numerous paradigms that are inclined by these two types.
Imperative Programming Paradigm (Procedural)
The main objective of the imperative programming paradigm development is to
decrease expenses of program development as well as maintenance. It is a style or
method of writing a program.
A procedural programming paradigm is derived from structured programming. It is
based on the concept of the procedure call. Procedures are also known as sequences,
subsequences, approaches, or functions. A Procedure contains a chain of instructions
coupled together to be carried out. .
Imperative Programming Paradigm is related to two other paradigms
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 18
Structured Programming Paradigm
Structured Programming means that the code will implement the instruction by
instruction one after the other. It does not support the possibility of skipping from one
instruction to some other with the assistance of any statement like GOTO and variables.
Functional Programming Paradigm
Functional Programming are specially designed to handle representative computation
and list processing applications. Functional programming is based on mathematical
functions and avoids changing state and variable data. The characteristics of
Procedural Programming are as follows ,
•
A huge program is broken down into small convenient procedures or
functions.
This decreases code repetition, which improves readability and maintainability of the
code.
•
Different functions can share data through global variables.
Functions are completely isolated, therefore if we want to share data, we need to declare
it in the upper scope.
•
Functions can change global data.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 19
In the mean-time global data are transferred from function to function; during the
progression of the transformation, the global data may be improved in function chains.
Top-down methodology.
Procedural programming follows the top-down approach, workflow is going from top
to bottom.
Below is an example of the main subroutine of a program coded using the procedural
paradigm.
Advantages of procedural programming
The coding is easy and simple.
•
The codes have the capability to be reused in numerous parts of the program.
•
The programming paradigm consumes less memory on the computer.
•
It is easier for tracking the flow of the codes in the program written in the
procedural programming paradigm.
•
The programming paradigm is considered as the best for general programming
to learn and implement.
Restrictions or disadvantages of procedural programming
•
Concentrates on functions rather than data.
•
In a huge program, it is difficult to classify the belonging of global data.
•
The use of global data is error-prone and it could be a barrier in case of
maintenance and developments.
•
The modification of global data involves the modification of those functions
using it.
•
Maintaining and improving the program code is still difficult because of global
data.
•
The procedural programming paradigm does not model the real-world problem
very well since functions are action-oriented and do not really agree to the
elements of the problem.
Object Oriented Paradigm
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 20
Object-Oriented Paradigm is where we focus on real life objects while programming
any solution.. The objective of an object-oriented program is to represent the real world
in code.
In the object-oriented paradigm, the problem is divided into smaller parts called objects,
and systems are built around objects. Objects are depictions of things that exist in the
real world that we wish to model in a computer system.
The characteristics of Object Oriented programming are as follows ,
•
Encapsulation
Encapsulation is taking data and keeping it securely from outside interfaces. These user
defined data types are called "classes," and one occasion of a class is an "object."
•
Abstraction
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 21
The capability to represent data at a very theoretical level without any details.
Abstraction facilitates the easy conceptualization of real world objects, by excluding
the pointless details of the object.
•
Inheritance
The process by which a class can be derived from a base class with all features of base
class and some of its own. This escalates code reusability,Classes are created in
hierarchies, and inheritance allows the assembly and methods in one class to be
distributed down the hierarchy. That means less programming is necessary when adding
functions to complex systems.
•
Polymorphism
This is the capability to exist in numerous methods, allows procedures about objects to
be formed whose precise type is not known until runtime.
A comparison between Procedural and Object Oriented Programming
Procedural
Object Oriented
Uses immutable data
Uses mutable data
Follows the declarative programming
model
Follows the imperative programming
model
Extends support to parallel programming Not appropriate for parallel
programming
The execution order of statements is not The execution of statements is very
the primary focus
important
Flow control is performed using function Flow control is performed through
calls
conditional statements and loops
Uses
recursion
concept
iterate collective data
to
Uses loop concept to iterate collective
data
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 22
No side effects of its functions
The method can have side effects
The focus in procedural programming is
The
“What are you doing”
programming is “How are you doing it”
focus
in
object
oriented
Event-driven Programming Paradigms
Event-driven Programming is when a program is designed to respond to user
involvement in various forms. It is known as a programming paradigm in which the
flow of program implementation is determined by “Events”. Events are any user
interaction, such as a click or key press, in response to prompt from the system.
Events are checked by a code (function) known as an “Event listener”. If the event
listener detects that an allocated event has happened, it will prompt a call-back function,
known as an event handler. As shown below is an example,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 23
The Characteristics of Event-driven Programming are as follows,
•
Time driven
Time driven in event driven programming is a paradigm, it is the code that runs on a
time prompt, this could be a part of the code that runs at a particular time, which could
be once a week or whenever a program is launched, this means it is a pre-set task.
•
Event handlers
Event handler is a function that takes place when a certain event occurs, they are
implemented in response to a certain event that takes place, this can be on a button,
when a button is clicked the code is executed, if the button is clicked again after that it
will execute again, this is an event handler.
•
Trigger functions
Trigger functions choose what code is executed when a particular event takes place,
they are used to choose when event handlers are executed for the event that took place,
most applications have a trigger function for each event that is probable to occur.
Events (Mouse, keyboard and user interface)
For the events inside a program to occur, they need to be generated, this is when the
user interacts with an object, which may be a button getting clicked by a mouse, events
can be generated in may different ways, it can be with your mouse, due to movement,
left clicking, right clicking or scrolling, the keyboard can also be used to begin events,
this can be from pressing certain keys, holding down certain keys or from being typed
onto the keyboard. The events occur due to code being assigned to something, for
example code might be assigned to a button, so when that particular button is clicked
the code is executed.
•
Pre-defined functions
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 24
A pre-defined function is a function that is built into the programming language.This
can be used as procedural so this code will run as soon as the program is ongoing, or
you can assign the code to a button, so that it can be triggered through an event.
Local
variables
A local variable is a variable that is stated within a method, that variable will only be
used by the method where it is stated, other methods will not use it.
•
Parameter passing
Parameter passing is used by a function, it tolerates a value to be passed through a
program, it can be used for many things, including an alarm or discovering a certain
character at a certain position, through on an alarm, the event doesn’t take place up until
a certain time has come, this is due to events.
Advantages of Event-driven Programming
•
Flexibility
Event-driven can be changed easily if the programmer desires something to be
changed. This paradigm lets the programmer to create a form of their requirements.
• Appropriate for Graphical Interfaces
Event-driven allows the user to choose different tools from the toolbar to directly create
what they need such as buttons, radio buttons, etc.
This also lets to put objects wherever they want them to be and can directly edit. Some
find it easier to directly click on the object that they want to edit.
•
Effortlessness of Programming
Can make the programming easier is that when using an event driven language such as
visual basic it generally has predictive coding so when the user is coding it will suggest
what you want to do from what you are typing.
•
Allows for more Interactive Programs
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 25
It allows for more interactive programs. Nearly all modern GUI programs use
eventdriven programming.
•
Using Hardware Interrupts
It can be executed using hardware interrupts, which will decrease the power used by the
computer.
•
Allows sensors and other hardware
It allows sensors and other hardware to effortlessly interact with the software.
Disadvantages / Contraints of Event-driven Programming
• Complexity
For simple programs, event-driven programming is often more complex.
• Less Logical
The flow of the program is usually less logical.
•
Difficult to find Errors
Errors can be more difficult to discover than with simpler, procedural programs.
•
Slower
Programs with complex GUIs (Graphical User Interface) may be slower to load and run
than simpler program
particularly if the RAM (Random Access Memory) is
insufficient.
•
Confusing
Programs with too many forms can be very confusing for the user.
2.2 Using the Procedural and Imperative Programming Paradigms in Python
Language.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 26
I have reused the function “calculate_total()” to calculate the “number_list1” and
“number_list2” total. The procedural style depends on on procedure calls to create
modularised code. Which means you can use functions to group the parallel type of
work and makes the overall code simpler. And get the Output as shown below ,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 27
Using the Object Oriented Programming Paradigms in Python Language. Object
Oriented Programming Characteristics
▪
Classes and Objects
▪
Encapsulation
▪
Inheritance
▪
Polymorphism
•
Class in Python Language
In the above
•
There is a Class named Student.
•
Constructors have the default name” __init__”. They are functions that are
indirectly labelled when an object of the class is formed.
•
All instance methods as well as the constructor have their first parameter as self.
•
Self refers to instance that is being referenced while calling the method.
•
“name” and “age” are the instance variables.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 28
•
Objects in Python Programming Language
In the above:
•
“S” is the name of the object that I’am creating based on Student class
•
Even though the class has three parameters (self, name, age), I will still pass
only name and age while creating an object, as we don’t need to refer self here.
It’s implicit.
•
Once an object is formed, you can refer to the attributes of the object using a
dot. For example, s.name refers to the name attribute of that individual object
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 29
•
Encapsulation in Python Programming Language.
This the concept of wrapping data such that the outside world has access only to
unprotected properties. Some properties can be hidden to reduce exposure. This is an
execution of data hiding.
In Python this is implemented by creating private, protected and public instance
variables and methods.
Private properties have double underscore (__) in the start, while protected properties
have single underscore (_). By default, all other variable and methods are public. Private
properties are available from within the class only and are not available for child class(if
inherited). Protected properties are accessible from within the class but are available to
child class too. All these constraints are removed for public properties. Given below is
the Output ,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 30
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 31
Inheritance in Python Programming Language
In inheritance, a “class” is inherited by another class (called subclass). The subclass
adds some attributes to superclass.
Shown below is the Output ,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 32
Polymorphism in Python Programming Language
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 33
Can produce a function that can take any object, allowing for polymorphism.
Event driven in Python Programming Language
Time driven Events
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 34
The turtle module in Python has a timer that can effect an event when its time is
up.When the event does happen, the handler is called ,and shown below is the event
when executed ,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 35
Key-press Events
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 36
It is needed to call the window’s listen method, or else it won’t respond to the
keypresses.
The handlers can be randomly complex functions that call other functions.
Pressing the “space” key on the keyboard calls function a4 (because it has been bounded
to a4). While executing a4, the window’s bye method closes the turtle window, which
causes the window’s “mainloop” call to terminate its execution.
The keys can be referred on the keyboard by their character code.
When the turtle window opens, It enables “t” to move by pressing the arrow keys.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 37
Mouse Events
A mouse event is a bit different from a keypress event because it’s handler needs two
parameters to receive a,b coordinate information telling where the mouse was when the
event happened.
This enables to move the turtle to an accurate coordinate position. So what this program
does is move the turtle (and draw a line) to anywhere the mouse is clicked on.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 38
Activity 3
3.1 Algorithms for vehicle tariff calculation for rents and hires.
Function 1: Rent calculation.
Function
RentCalculation(RegNo,RentedDate,ReturnDate,WithDriver)
/*Calculate No of Elapsed Days
DateDiff=ReturnDate - RentedDate
/*calculate months,weeks,days
Months=DateDiff / 30
Remainder = DateDiff % 30
Weeks = Remainder / 7
Days = Remainder % 7
Find the required vehicle record from vehicle table If
(found)
show VehicleType,MonthlyRate,WeeklyRate,DayRate,DriverRate
Amount= Months*MonthlyRate + Weeks*WeeklyRate + Days*DayRate
If(With_Driver == true)
Total_Amount= Amount+Date_Diff*DriverRate
Else
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 39
Total_Amount=Amount
End if
Print("Total amount",total_amount")
Else
Print("Vehicle Not found")
End if
End function
Function 2: Day tour.
Function day_tour(packageid,start_time,end_time,start_km,end_km)
Find the required record from package_table
If found()
Noofhours=end_time-start_time If
no_of_hours>max_hors then
ex_hours=no_hours-max_hours
ex_hour_charge=ex_hours*ex_hour_rate
else
ex_hours=0 endif
ex_hour_charge=ex_hours*ex_hour_rate
no_of_km=end_km-start_km
if(no_of_km>max_km)
ex_km=no_km-
max_km
else
ex_km=0
endif
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 40
ex_km_charge=ex_km*ex_km_rate
/* calculate total cost
total_cost=package_rate+ex_hour_charge+e
x_km_rate print("total cost:",total_cost) else
print("record not found")
endif end function
Function 3: Long tour.
Function Long_tour(Pid,Start_date,End_date,Start_KM,End_KM)
Find the required record from Package_table
If found()
nDays=End_date-
Start_date
NoofKM=End-Start_KM
permitted_KM=Max_KM * NoofDays
if(NoofKM>permitted_KM)then
Ex_KM=NoofKM-permitted_KM
else
Ex_KM=0
Endif
ExKMCharge=Ex_KM * ExKMRate
Print("Extra KM Charge",EXKMCharge)
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 41
/*calculate Base hire*/
BaseHireCharge=PRate * NoofDays
Print("Extra Base Hire Charge",BaseHireCharge)
/*calculate Night Charge*/
NightCharge=(VehiNightRate + DrNightCharge) * (NoofDays -1)
Print("Owner Night Charge",NightCharge)
Total_cost=BaseHireCharge + NightCharge + ExKMCharge
Print("Total cost :",TotalCost)
Else
Print("Record Not Found")
Endif
End function
3.2 Database structure for keeping the tariffs for vehicle types and different
packages and Console Applications.
The Database structure for Packages is displayed below,
Packages Design
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 42
Packages Data
The Database structure for Vehicles is displayed below,
Vehicle Design
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 43
Vehicle Data
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 44
Console Applications
Rent Calculation
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 45
The Output for Rent calculation,
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 46
Day Tour
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 47
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 48
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 49
Long Tour
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 50
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 51
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 52
3.3 Integrated Development Environment (IDE)
What is an IDE (Integrated Development Environment)?
An integrated development environment (IDE) is a software suite that combines basic
tools necessary to write and test software. IDEs provide interfaces for users to write
code, organize text groups, and automate programming redundancies. IDE Common
Features are,
•
Text editor
Virtually every IDE will have a text editor designed to write and manipulate source
code. Some tools may have visual components to drag and drop front-end components,
but most have a simple interface with language-specific syntax highlighting.
•
Debugger
Debugging tools support users in identifying and resolving errors within source code.
They often simulate real-world scenarios to test functionality and performance.
Programmers and software engineers can usually test the various sections of code and
identify errors before the application is released.
•
Compiler
Compilers are components that translate programming language into a form that
machines can process, such as binary code. The machine code is analysed to confirm
its accuracy. The compiler then parses and optimizes the code to optimize performance.
•
Code completion
Code complete features assist programmers by intelligently identifying and inserting
common code components. These features save developers time writing code and
reduce the possibilities of errors and bugs.
•
Programming language support
IDEs are normally specific to a single programming language, though several also offer
multi-language support. As such, the first step is to discover which languages it will be
coding in and narrow of the prospective IDE list down accordingly.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 53
•
Integrations and plugins
With the name integrated development environment, it is no surprise that integrations
need to be considered when looking at IDEs. The IDE is the development portal, so
being able to include all the other development tools will improve development
workflows and productivity. Poor integrations can cause several issues and lead to many
headaches, so make sure to understand how well a potential IDE fits into the ecosystem
of existing tools.
4.1 The system to calculate vehicle hire amounts and record
database record for customer billing and management reporting for Ayubo.
Login Interface
Main Menu Interface
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 54
Package Details Interface
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 55
Vehicle Details Interface
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 56
Rent Calculation Interface
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 57
Day Tour Interface
Long Tour Interface
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 58
Backend Code for Rent Calculation
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 59
Backend Code for Day Tour Calculation
Backend Code for Long Tour Calculation
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 60
4.2 What is debugging an application?
Debugging is the process of identifying and eliminating of existing and potential errors
(also called as ‘bugs’) in a software code that can cause it to behave unexpectedly or
crash. To prevent incorrect operation of a software or system, debugging is used to find
and resolve bugs or defects. When various subsystems or components are firmly
coupled, debugging becomes harder as any change in one component may cause more
bugs to appear in another. Sometimes it takes more time to debug a program than to
code it.
The debugging process,
1. Reproduce the problem.
2. Describe the bug. Try to get as much input from the user to get the precise reason.
3. Capture the program snapshot when the bug appears. Try to get all the variable values
and states of the program at that time.
4. Examine the snapshot based on the state and action. Based on that try to find the
cause of the bug.
5. Fix the existing bug, but also check that any new bug does not occur.
▪ The features available in Visual studio IDE for
Debugging,
When running the app in Visual Studio for the first time, we may start it by pressing the
green arrow button Start Debugging in the toolbar (or F5). By default, the Debug value
appears in the drop-down to the left. If you are new to Visual Studio, this can leave the
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 61
impression that debugging the app has something to do with running the app which it
does but these are basically two very different tasks.
Select a Debug build
A Debug value indicates a debug configuration. When we start the app (press the green
arrow or F5) in a debug configuration, we start the app in debug mode, which means
we are running the app with a debugger attached. This enables a full set of debugging
features that can be used to help find bugs in the app.
If we have a project open, choose the drop-down selector where it says Debug and
choose Release instead.
Select a Release build
When we switch this setting, we change our project from a debug configuration to a
release configuration. Visual Studio projects have separate release and debug
configurations for our program. We build the debug version for debugging and the
release version for the final release distribution. A release build is optimized for
performance, but a debug build is better for debugging.
•
Fix an exception
When i have fixed all the red squiggles and resolved or at least investigated all the green
squiggles, I am ready to start the debugger and run the app.
Press F5 (Debug > Start Debugging) or the Start Debugging button Start Debugging in
the Debug toolbar. At this point, the sample app throws a Serialization Exception (a
runtime error). That is, the app blocks on the data that it is trying to serialize. Because
I started the app in debug mode (debugger attached), the debugger's Exception Helper
takes you right to the code that threw the exception and gives a helpful error message.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 62
•
Break points
I set breakpoints wherever you want to pause debugger execution. I can break execution
when a function is called. When i debug, execution pauses at the breakpoint, before the
code on that line is executed. This is useful, for example, when you know the function
name but not its location. It is also useful if you have functions with the same name and
you want to break on them all (such as overloaded functions or functions in different
projects).
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 63
4.3 Coding standards
They are a series of measures that can be defined for a particular programming language
specifying a programming style, the methods, & different procedures. These procedures
can be for various characteristics of the program written in that language. They can be
considered as essential attributes of software development.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 64
A coding standard makes sure that all the developers working on the project are
following certain specified guidelines. The code can be easily understood and proper
consistency is maintained.
Consistency has a positive impact on the quality of the program and one should maintain
it while coding. Also, it should be taken care that the guidelines are consistently
followed across different levels of the system and they do not oppose each other. The
finished program code should look like that it has been written by a single developer,
in a single session.
The coding standards that I have used in my application development are,
• Code Comments and Proper Documentation
It is a good practice to comment while writing code. It helps other developers to
understand your code. With the use of the Integrated Development Environment and
other tools, commenting can be utilized in many different ways. It is advisable to start
every method or routine with the comment specifying what a routine, method or a
function does, about its various parameters, its return values, errors and exceptions (if
any). Also, the role of each file and class, their contents and even the steps of complex
codes should be summarized in the comments.
•
Use of Indentation
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 65
It is advisable to make use of indentation while writing the code. There is no particular
style defined, but any style can be chosen for writing code. However, a consistent
indentation style should be followed throughout the code. For Instance,
•
Using Variables
Variables are the names I gave to computer memory locations which are used to store
values in a computer program. In most or all software programming languages,
variables work like containers to hold numbers, phrases, or other important stuff used
in numerous places in my code.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 66
Why a coding standard is necessary for the team as well as for the individual.
Coding standards are a set of guidelines, best practices, programming styles and
conventions that developers follow to when writing source code for a project. All big
software companies have them. A coding standards document tells developers how they
must write their code. Instead of each developer coding in their own preferred style,
they will write all code to the standards outlined in the document. This makes sure that
a large project is coded in a reliable style parts are not written differently by different
programmers. Not only does this solution make the code easier to understand, it also
ensures that any developer who looks at the code will know what to expect throughout
the entire application.
Working Independently. In this case programmer has to follow those coding standards
because the programmer needs to state an efficient well working computer application.
Because of that the inner logic of the program should be clearly stated, that means the
code. If the programmer works according to the coding standards the code will be not
only simpler but also will be efficient too. When proper coding standards are used ,
there will be no errors in the specific program. In that case the testing stage will be
easier. Because of that the deployment process of the program will be efficient so the
programmer can develop the program within the given time period.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 67
When you start sharing code or start reading code shared by others, you begin to realize
that not everybody writes their code they way you do. You see that other, ugly coding
style, and think “everybody needs to write in the same style that I do so that things are
easier to understand.” Therefore, it is natural that everybody wants their own ways
turned into the standard, so they don’t have to change their habits.
If the entire team work according to a specific coding standard the combining process
will be easier and the wastage of the time will be decreased because of that. So if the
programmers use same standards it will make things much easier for the team.
Likewise, the coding standards is not only important in working as a team but also it
benefits in working as individual as well.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 68
Acknowledgement
The success and final outcome of this assignment required a lot of guidance and
assistance from Mrs.Shifani Mohideen and I am extremely fortunate to have got this all
along the completion of my assignment work. Whatever I have done is only due to such
guidance and assistance and I would not forget to thank her. I respect and thank all my
colleagues at the Esoft metro campus, for providing me all support and guidance which
made me complete the assignment on time . I am extremely grateful to be a part of this
amazing team. Thanking you,
P.V.Godrick Naveen
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 69
Grading Rubric
Grading Criteria
Achieved
Feedback
LO1 Define basic algorithms to carry
out an operation and outline the
process of programming an
application.
P1 Provide a definition of what an
algorithm is and outline the process in
building an application.
M1 Determine the steps taken from writing
code to execution.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 70
D1 Examine 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, object orientated and
event-driven programming, conduct an
analysis of a suitable Integrated
Development
Environment (IDE)
P2 Give explanations of what procedural,
object orientated, and event driven
paradigms are; their characteristics and the
relationship between them.
M2 Analyze the common features that a
developer has access to in an IDE.
D2 Critically evaluate the source code of an
application which implements the
programming paradigms, in terms of the
code structure and characteristics.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 71
LO3 Implement basic algorithms in
code using an IDE.
P3 Write a program that implements an
algorithm using an
IDE.
M3 Use the IDE to manage the
development process of the program.
D3 Evaluate the use of an IDE for
development of applications contrasted
with not using an IDE.
LO4 Determine the debugging
process and explain the importance
of a coding standard
P4 Explain the debugging process and
explain the debugging facilities available
in the IDE.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 72
P5 Outline the coding standard you have
used in your code.
M4 Evaluate 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.
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 73
References
(Bhatt, 2019)
https://medium.com/@bhattshlok12/characteristics-of-an-algorithm-49cf4d7bcd9
Stevenson, Joseph.
http://neonbrand.com/procedural-programming-vs-object-oriented-programmingareview/ (Lynch, A., 2020)
https://www.edrawsoft.com/flowchart/program-flowchart-definition.html
(Naomi Nishimura)
http://www.cs.cornell.edu/courses/cs482/2003su/handouts/pseudocode.pdf
Jacobson, I., Christerson, M., Jonsson, P. and Overgaard, G. (1992) Object-Oriented
Software Engineering: A Use Case Driven Approach, Addison-Wesley.
Booch, G. (1994) Object-Oriented Analysis and Design, Addison-Wesley.
Macharia, N., 2018. Noteworthy.
https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide29956242698
(Sehgal, K., 2017. medium.com.)
https://medium.com/karuna-sehgal/a-simplified-explanation-of-the-big-o-notation82523585e835
(Krisno, R., 2020. Towards Data Science)
https://towardsdatascience.com/demystifying-binary-search-bed0274e27e7
Brian W. Kernighan/Rob Pike The Practice of Programming. Addison-Wesley, 1999.
Jonathan B. Rosenberg. How Debuggers Work. John Wiley & Sons, London, 1996.
(Rouse, M., 2018. techtarget.)
https://searchsoftwarequality.techtarget.com/definition/integrateddevelopmentenvironment
Godrick Naveen - HND in Computing |Programming Assignment
01
Page | 74
Download
Study collections