Sharini Himaya - Unit 01 Programming Assignment - Reworded 2021
Sharini Himaya - Unit 01 Programming Assignment - Reworded 2021
student work?
Give details:
Internal Verifier
signature Date
Programme Leader
signature (if required) Date
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.
LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a su
Integrated Development Environment (IDE).
LO4. Determine the debugging process and explain the importance of a coding standard.
Pass, Merit & Distinction Descripts P4 P5 M4 D4
Resubmission Feedback:
* Please note that grade decisions are provisional. They are only confirmed once internal and external moderation has taken
place and grades decisions have been agreed at the assessment board.
Assignment Feedback
Formative Feedback: Assessor to Student
Action Plan
Summative feedback
Assessor Date
signature
Student Date
signature
Computing
Unit 01: Programming
Assignment 01
Sharini Himaya
COL00138107 / E159204
1. A Cover page or title page – You should always attach a title page to your assignment.
Use previous page as your cover sheet and make sure all the details are accurately
filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom, right margins and 1.25” for the left margin of each page.
1. The font size should be 12 point, and should be in the style of Time New Roman.
2. Use 1.5 line spacing. Left justify all paragraphs.
3. Ensure that all the headings are consistent in terms of the font size and font style.
4. Use footer function in the word processor to insert Your Name, Subject, Assignment
No, and Page Number on each page. This is useful if individual sheets become detached
for any reason.
5. Use word processing application spell check and grammar check function to help editing
your assignment.
Important Points:
1. It is strictly prohibited to use textboxes to add texts in the assignments, except for the
compulsory information. eg: Figures, tables of comparison etc. Adding text boxes in the
body except for the before mentioned compulsory information will result in rejection of
your work.
2. Carefully check the hand in date and the instructions given in the assignment. Late
submissions will not be accepted.
3. Ensure that you give yourself enough time to complete the assignment by the due date.
4. Excuses of any nature will not be accepted for failure to hand in the work on time.
Sharini Himaya | Programming – Assignment 01
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
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.
[email protected]
Student’s Signature: Date: 28/12//2022
(Provide E-mail ID) (Provide Submission Date)
Submission Format
1. Written Report
This submission is in the form of an individual written report. This should be written in a concise, formal
business style using single spacing and font size 12. You are required to make use of headings, paragraphs
and subsections as appropriate, and all work must be supported with research and referenced using the
Harvard referencing system. Please also provide a bibliography using the Harvard referencing system. (The
recommended word count is 1,500–2,000 words for the report excluding annexures)
3. Presentation
With the submitted system student should do a presentation to demonstrate the system that was
developed. Time allocated is 10 to 15 min. Student may use 5 to 10 PowerPoint slides while doing the
presentation, but live demonstration of the system is required. Evaluator will also check the ability to
modify and debug the system using the IDE.
LO1. Define basic algorithms to carry out an operation and outline the process of
programming an application.
LO4. Determine the debugging process and explain the importance of a coding
standard
Activity 1
A. The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
Fn = F n-1 + F n-2
n! = n * (n - 1) * …….. 1
Define what an algorithm is and outline the characteristics of a good algorithm. Write the
algorithms to display the Fibonacci series and the factorial value for a given number using
Pseudo code. Determine the steps involved in the process of writing and executing a
program.
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
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.
Ayubo Drive is the transport arm of Ayubo Leisure (Pvt) Ltd, an emerging travel & tour
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.
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 are also 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
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
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.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.
18
D1 Evaluate the implementation of an algorithm in a suitable
language. Evaluate the relationship between the written
algorithm and the code variant
Additionally, I would like to thank my classmates for their cooperation and assistance in
making this assignment possible and I want to express my gratitude to my parents for
their immense love and blessings.
Finally yet importantly, I want to thank ESOFT Metro Campus for assisting me during
my assignment.
I will never forget how you inspired me, and I sincerely hope that you will continue to
love and support me in all of my future pursuits.
Sincerely,
Sharini Himaya.
WHAT IS AN ALGORITHM?
An algorithm is termed as a step by step procedure that can be used to perform a specific
task or action. An algorithm developed for a particular task can be defined as a finite set
of instructions, each of which has a defined meaning and can be finished in a finite
amount of time with a finite amount of effort, according to (Bullinaria, 2019). An
algorithm must therefore be precise enough for people to comprehend it. Moreover, it is
suggested by (Gillis, 2022) that algorithms can be divided into a number of groups,
including natural languages, programming languages, pseudocode, flowcharts, and
control tables. Expressions in natural languages are uncommon because they are more
complicated. A computer's algorithms are typically expressed in programming
languages. An algorithm is frequently mistaken for machine code. This assertion is
untrue. An algorithm can be written in plain English or any other language that the
programmer is familiar with. It clearly displays the beginning and the end by having a
"Start" and an "End" statement. In order to find a solution to a problem or to prepare the
way for doing so, algorithms are designed. The two types of algorithms that
programmers and beginners to programming use the most are pseudocodes and
flowcharts.
C. The Fibonacci numbers are the numbers in the following integer sequence.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
Fn = F n-1 + F n-2
START
Step 1 → Take integer variable A, B, C
Step 2 → Set A = 0, B = 0
Step 3 → DISPLAY A, B
Step 4 → C = A + B
Step 5 → DISPLAY C
Step 6 → Set A = B, B = C
Step 7 → REPEAT from 4 - 6, for n times
STOP
IF fib_num equals to 1
DISPLAY 1
IF fib_num equals to 2
DISPLAY 1, 1
End procedure
OR
START
First, we should tell how many terms we want to display
nterm = Enter the value
num1 = 0
num2 = 1
count = 0
IF nterm <= 0:
DISPLAY "Enter a valid number"
ELSE IF nterm == 1:
DISPLAY "The Fibonacci sequence of the numbers up to", nterms, ": "
DISPLAY num1
ELSE
DISPLAY "The Fibonacci sequence of the numbers is:"
while count < nterm:
DISPLAY num1
numTH = num1 + num2
num1 = num2
Fibonacci Series produces a new number by adding two earlier values. The
Fibonacci sequence begins with the two numbers F0 and F1.
D. 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
ELSE IF num == 0
DISPLAY “The factorial of 0 is 1”
ELSE
for i in range (1, num + 1)
factorial = factorial*i
DISPLAY "The factorial of", num,"is", factorial
END
A dry run is the manual execution of a programmer's code to check the value of
variables. Therefore, a printout of the code would typically be used during a dry run. To
verify that a variable was accessed and updated in accordance with expectations, the
It is used to identify logical errors therefore, they will not assist in figuring out
execution errors.
(BBC, Dry run - testing - higher computing science revision - BBC bitesize)
1 6 1
2 1 1 1
3 2 1 2
4 3 2 6
5 4 6 24
6 5 24 120
7 6 120 720
1. Analyzing the problem: Obtaining the following information is required for the
initial step of programming. The problem needs to be thoroughly defined in this
step. Input/output, processing requirements, memory requirements, error
handling, and integrating with other programs are all variables that need to be
taken into consideration at this stage. These items are crucial for the programmer
since they give him the foundation for planning his program and for managing
any potential problems in the future. The process ends when all the
programmer’s questions have been resolved and the requirements of the program
are understood.
Ex: Sum of two numbers (N1+N2)
2. Algorithm design: Each of the procedures that must be followed at various levels
are stated at this stage. These are written in simple English. It might be described
as a strategy. Algorithms, which are similar to equations, are used in programs to
instruct computers on what to do. The goal of the programmer is to design
simple and understandable algorithms. Modularization is a logical hierarchical
Sharini Himaya | Programming – Assignment 01
manner in which algorithms are initially stated. The programmer constructs a
logical thought process for the machine to follow using modules or a complete
idea. The program is then analyzed in further detail using pseudocode.
Pseudocode connects the program's rules to the machine by using words like if,
else, and then.
BEGIN
Input N, M
Sum = N + M
Display Sum
END
3. Flowchart: Flowcharts is a graphical tool that depicts the steps or stages that must
be inserted when running a program. Now, all the steps listed in the second stage
are given diagrammatically to make them easier to understand. The creation of
flowcharts aids in streamlining our programming process by allowing us to
establish logic and identify and correct design flows.
4. Coding: Any program must be coded or developed after it has been designed. The
programmer writes the problem-solving instructions in computer language in this
stage. Every phase of the coding process is based on the data we gathered in the
previous stages. The language that is chosen relies on the needs and resources
that language offers. All syntax issues, spelling mistakes, comma absences, and
empty labels are removed throughout this process.
5. Debugging: How many times we check there is a potential that mistakes could
happen while we are coding, we delete all of the errors in the program at this
point. Here, a process known as DRY RUN is used to manually run the software
several times until all mistakes have been resolved and the system is error-free.
Un-initialization of variables.
Reversing of order of operands.
Confusion of numbers and the characters.
Inverting of conditions.
7. Final Output: Last but not the least the software is handed the TRUE DATA once
it has completed all of the aforementioned steps. Here, the programmer
anticipates successful program outcomes and complete program efficiency at the
end of testing.
Growth rate
Complexity measure O ()
How much time does it need
How much memory space does it require
Concrete
Unambiguous
Best performance: the item we search for is in the first position; examines one
position
Worst performance: item not in the array or in the last position; examines all
positions
Average performance (given that the item is in the array): examines half of the
array
Worst case - item in the last possible division; the maximal number of times an array of
length N can be divided is log2 N
Average case: item is found after performing half of the possible number of divisions; ½
log2 N
For getting a general idea of running time: average case; however, often difficult to
establish. For choosing between several available algorithms: helps to know what the best
is.
Machine Independence
Basic operations are operations, which take constant time (at most time C for some
constant C). In other words, time required to perform the operation does not grow with
the size of the operands, or is bounded by a constant. If we are not sure how operations
are implemented, we have to exercise judgement: can something be in principle
implemented as a constant time operation?
For example, adding two 32-bit integers can be, but adding a list of 32-bit integers
cannot: it is going to take longer for a longer list.
n1, n2 = 0, 1
count = 0
if nterm <= 0:
print("Please enter a positive integer")
elif nterm == 1:
print("Fibonacci sequence upto", nterm, ":")
print(n1)
else:
print("Fibonacci sequence:")
while count < nterm:
n1 = n2
n2 = nth
count += 1
In the above given example, the student have stored the number of terms in nterm.
Then initialized the first term to 0 and the second term to 1.
As per the program if the number of terms is more than 2, it uses a while loop to find the
next term in the sequence by adding the previous two terms. We then interchange the
variables and proceed on with the process.
In the above given example, the student have declared a variable called Num that
takes an integer as an input from the user. Then declared a variable factorial and
assigned 1. Next, checked if the user enters the number less than 1, then it returns the
factorial does not exist for a negative number (-10). If it returns false, then we check
Num is equal to 0, it returns false the control transfers to the else statement and prints
the factorial of a given number.
A function called "calctotal" that was initially given appears in the above image. The
mechanism used by this function to calculate the sum of all the numbers in a list is
fundamental. The variable x displays the numbers in the list as part of the "For"
iteration method used to locate this. Here, the list's total will be determined by
repeatedly adding its x value (the list's integers). Later, the list was made accessible
as lists A and B containing integers. The line that needs to be written in the output is
specified in the next line's print command, and listA and listB are used as arguments
for the function. The function calctotal will be run by the two list numbers overall,
and their output will be displayed as follows.
The procedural paradigm has a top-down organizational structure. This is as a result
of the similarities to structural programming that it inherits. It utilized the "For"
iteration loop and sequence to process the code in the preceding code snippet. The
There are four main principles of the OOP concept. They are:
Encapsulation: Encapsulation is the process of combining data and procedures into
a single entity.
Inheritance: This is how one class is derived from another class. The class from
which it is acquired is known as the parent class, and the inherited class is referred to
as the child class.
Polymorphism: An idea where a single object has various behaviors is what this
term refers to.
Abstraction: This is the process of hiding the detail of the information and
simplifying how it is presented.
Labels, textboxes, and buttons were used to develop the calculator. The calculator's
main function was to combine the values entered in textboxes 1 and 2 and then,
when a button was clicked, to execute the two values as desired. To hold the double
data type values entered in the textboxes, 3 public variables were created. The
procedure followed by the software was to extract the values from both textboxes
and save them as double data in the public variables. Following the execution of
both stored variables in accordance with the symbol (button), the response contained
in the public variable will be converted to a string and supplied in the answer
textbox. The clear button will change all the public variables and the textbox into
empty fields.
The code snippet depicts the general structure of an event-driven diagram.
When an event is triggered by a click, event handlers will be accessible, and the
code block inside will be executed to produce a useful output. The application offers
Sharini Himaya | Programming – Assignment 01
a straight-forward route and does not allow for any process diversions. Every
component of the software must have codes delivered repeatedly as needed. If a tool
in the design view was to produce an output, it would need to be coded.
When compared to other languages, event driven programming has a few distinctive
properties. Especially the welcoming environment that is GUI-based. The simplest
tools in the software can be used by the developer to build their own GUI-based
system. It is simple to drag and drop into the design plane and then code it
appropriately thereafter. Because they will be used to produce events, the buttons are
the primary emphasis of the design view.
Other tools will primarily be utilized to add data or to display it to the user. Overall,
these technologies give developers more options. The developer must code each and
every output of the instances. Because all of the choices and loops in the software
are to be made by the developer, that means they have a big work ahead of them.
Another aspect of event-driven programming is the ease and simplicity of the
coding. In contrast to OOP principles, the majority of scripts and tools are displayed,
making them easier to use. They give a precise understanding of the code that was
utilized and the reason it was developed.
Overall, it is evident from the facts shown above that the event driven paradigm is
adopted by the majority of developers and has some of the most distinctive qualities.
BEGIN RentCalc
INPUT StartDate
INPUT EndDate
INPUT DailyRate
INPUT MonthlyRate
INPUT WeeklyRate
INPUT DriverRate
BEGIN DayTourCalc
INPUT StartTime
INPUT EndTime
INPUT StartKMRead
INPUT EndKMRead
MaxKM = 100
MaxHours = 10
RateExtraKM = 50
WaitingRate = 100
BaseCharge = 6000
Similar to Renting the day tour was done according to a single vehicle type. The
base prices and other prices may change according to the vehicle type. Few
variables regarding the start and end of the KM reading and hours are entered.
Other variables are provided with values that vary depending on the vehicle.
Total hours and total KM are found to identify whether they have exceeded the
max hours and max Km limit. If they are exceeded, penalties including waiting
fees and extra mile fees will apply. The total hire fee will increase to include
these. Finally the required details will be displayed.
BEGIN LongHireCalc
INPUT StartDate
INPUT EndDate
INPUT StartKMRead
INPUT EndKMRead
Sharini Himaya | Programming – Assignment 01
MaxKmRead = 500
BaseCharge = 20000
ExtraKMRate = 40
OvernightParkRate = 500
OvernightDriverRate = 1000
NoOfDays = 2
DISPLAY BaseCharge
DISPLAY ExtraKMCharge
DISPLAY OverNightCharge
DISPLAY TotalHireCharge
END
The system's logical database structure is shown in the figure below. The lines depict the
relationships between the tables, including primary and foreign keys. Here, foreign keys
are utilized to extract data from a certain database so that it can be used in the
calculation. One of the most crucial components of the system is this one. These records
will be utilized to calculate the tariff and retain records pertaining to vehicle rates and
Creating Database
Vehicle Table
Based on the packages for each vehicle, the data input in the above tables will be
utilized to determine various hire rates and rental rates. These two fundamental tables
will be used to calculate the three key functions listed in the brief. The table to rent, day
trips, and extended tours are shown in the following pictures.
Day-Tours Table
The vehicle interface appears in this picture above. This covers all of the data that I have
entered into the vehicle table's database. Through these textboxes, you can add data to
the vehicle table, and it will be preserved there.
The functions offered by this package interface are identical to those of automobiles.
The relevant textboxes data will be recorded in the backend packages database. The
database table is made available as proof by the view button. The Interfaces are
developed as you see above to illustrate the many steps in the system that calculate and
save data in databases.
To make it simpler for the agency's administrator to add and update data in the system, I
designed a car interface and a packages interface. Although it won't be visible to
customers, the administrator can still access it.
The IDE's primary features that assist developers in successfully and error-free
application development are listed down above.
(What is an IDE?,2019)
It is evident from the above features and contrasts that text editors and IDEs differ
greatly from one another. This comparison's conclusion is that the decision of whether
to use an IDE or a text editor to create a particular application depends on the developer
and the needs of the program itself. Since both IDEs and text editors are widely used in
the IT industry, developers tend to use IDEs for much more advanced works due to the
benefits listed above.
Vehicle page: Contains the ability to examine vehicles and their details as well as
add, update, and delete vehicles for the admins use. The entered and displayed
data will have a direct connection to the database. The information entered in
this table will be used for project functions.
Packages page: Allows administrators to view, add, update, and delete packages
from its database. The information submitted here will be utilized to compute
rates in the functions, much like the vehicle page.
Day Tour calculation page: This is another important project function. This
determines a customer's Day rate based on their package and the vehicle they
used. The user will see all relevant data along with any additional costs.
Long Tour calculation page: Here is where the project's final task is included.
Similar to day tours, the pricing for a long tour will be determined using the
function provided, and the user will be shown the final result along with any
additional fees.
The Ayubo Travels menu page is depicted in the image up above. These three are the
main purposes for the project. The student left out the vehicle and packages page
because this is a user model. Three buttons are used to represent the three functions, and
clicking any of them will trigger an event handler that will lead the user to the
appropriate page.
The following image includes the codes used for the buttons which will redirect the page
to the respectful page.
The data categories in the vehicle interface match those in the database, and the view
button displays the information in the database table. This task is carried out using the
data grid tool. Four buttons were utilized by the learner to access various system
features. Since they are required to store the tariff rates in the database table, these
buttons are actually used in all other interfaces.
The buttons which were used are as follows:-
Add – Add button is used to enter data into the database.
Update – Update button is used to change data in the database. The
primary key will be used to identify the record that has to be updated
and then the updatable content will be added in the necessary textbox.
Delete – Delete button is used to delete a record from the table
The above image contains the code used to add data into the vehicles table in the
database. The add button was filled with these codes and during the click the event will
run as provided and the output with be provided as mentioned in the message box result.
The same code was used in all other add buttons only the necessary variables such as the
textbox name and the row names were changed. The below image provides the message
box of a successful data entry.
Update button fulfills the task of editing the already entered data in the database. The
process of this feature is that the record is identified by its unique data (primary key)
and then the data which has to be updated will be added. This can be a useful technique
in various instances. The following image shows the code block for the update button.
Delete Button
Delete button deletes a whole record based on its primary key produced. The following
code block was used to fulfill this task.
View Button
View button provides the simple facility of viewing the content in the database table at a
glance inside a data grid. The code used for this button is as follows.
The above shown images and interfaces provide a clear picture of the system created in
the visual studio environment. This small system created is able to calculate hire
amounts and record them in the database for customer billing and management reporting
for Ayubo drive. The created system includes of three main services provided by the
Ayubo travels and all these functions are successfully executed by the system. The
obtained final values will be saved in their respective databases. Features such as
adding, deleting, updating and viewing are entered in the system. In overall an
automatic billing and management report system was successfully built for Ayubo drive
according to their requirements provided
2. Indentation
Using indentation in the code can make the code easier to read and understand. It’s the
developer’s responsibility to create a code which can be easily readable by another
fellow developer. These are few methods to properly adjust the space in the program.
• A space has to be provided after a comma between two function arguments.
• A new nested block has to be properly indented and spaced
• Indentation has to be provided at the beginning and at the end of each block
With the above mentioned points and explanation it’s clear that following a code
standards can help an individual prosper their coding skills which will be helpful in a
Sharini Himaya | Programming – Assignment 01
professional level. As a whole in the conclusion I would like to say that following a
coding standard can massively benefit both an individual and as well as a team to move
forward in the IT industry. The comparisons and explanations shown above prove that
coding standards are necessary for team as well as for the individuals too.
7. Dry run - testing - higher computing science revision - BBC bitesize (no date)
BBC News. BBC. Available at:
https://www.bbc.co.uk/bitesize/guides/zg4j7ty/revision/3#:~:text=A%20dry%20ru
n%20is%20the,print%20out%20of%20the%20code