0% found this document useful (0 votes)
60 views106 pages

Programming Assignmet (1) - 231101 - 100644

The document discusses an assignment for a programming unit. It provides guidelines for submitting the assignment, which involves designing and implementing a GUI-based system using an integrated development environment. It lists the student and unit details, outlines the submission format, and includes declarations about plagiarism and submitting on time.

Uploaded by

Mahe Clicks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views106 pages

Programming Assignmet (1) - 231101 - 100644

The document discusses an assignment for a programming unit. It provides guidelines for submitting the assignment, which involves designing and implementing a GUI-based system using an integrated development environment. It lists the student and unit details, outlines the submission format, and includes declarations about plagiarism and submitting on time.

Uploaded by

Mahe Clicks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

Pearson Higher Nationals in

Computing
Unit 01: Programming Assignment 01

Aliyar Mohommed Aadhil Unit1-pogramming


Assignment 01
Higher Nationals
Internal verification of assessment decisions – BTEC (RQF)

INTERNAL VERIFICATION – ASSESSMENT DECISIONS

Programme title Higher National Diploma in Computing

Assessor Internal Verifier


Unit 01 : Programming
Unit(s)

Assignment title
Aliyar Mohommad Aadhil
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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 1


Confirm action completed
Remedial action taken

Give details:

Assessor signature Date

Internal Verifier
Date
signature

Programme Leader
Date
signature (if required)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 2


Higher Nationals - Summative Assignment Feedback Form
Student Name/ID Aliyar Mohommad Aadhil/ E161815/COL00137968
Unit Title
Assignment Number Assessor
Date Received 1st
Submission Date
submission
Date Received 2nd
Re-submission Date
submission
Assessor Feedback:
LO1. Define basic algorithms to carry out an operation and outline the process of programming an application.

Pass, Merit & Distinction Descripts P1 M1 D1

LO2. Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a suitable
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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 3


Formative Feedback: Assessor to Student

Action Plan

Summative feedback

Feedback: Student to Assessor

Assessor Date
signature

Student Date
signature

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 4


Pearson Higher Nationals in
Computing
Unit 01: Programming
Assignment 01

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 5


General Guidelines

1. A Cover page or title page – You should always attach a title page to your assignment.
Use previous page as your cover sheet and make sure all the details are accurately filled.
2. Attach this brief as the first section of your assignment.
3. All the assignments should be prepared using a word processing software.
4. All the assignments should be printed on A4 sized papers. Use single side printing.
5. Allow 1” for top, bottom , right margins and 1.25” for the left margin of each page.
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.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 6


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.


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.

[email protected] 28/12/2022
Student’s Signature: Date:
(Provide E-mail ID) (Provide Submission Date)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 7


Higher National Diploma in Computing
Assignment Brief
Student Name /ID Number Aliyar Mohommed Aadhil/E161815/COL00137968

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.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 8


Unit Learning Outcomes:

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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 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.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 10


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.

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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 11


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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 12


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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 13


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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 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.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 15


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.

LO4 Determine the debugging process and explain


the importance of a coding standard

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 16


P4Explain the debugging process and explain the debugging
facilities available in the IDE.

P5Outline the coding standard you have used in your code.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 17


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.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 18


Table of Contents
ACTIVITY 1 ............................................................................................................................ 22
ALGORITHMS ................................................................................................................... 22
What is an algorithm? ...................................................................................................... 22
Characteristics of an algorithm. ....................................................................................... 23
Algorithms to display the Fibonacci series and the factorial value using Pseudo code ...... 24
Fibonacci series ................................................................................................................ 24
Algorithms to display the Fibonacci series using Pseudo code ....................................... 25
Algorithms to display the factorial value using Pseudo code .......................................... 25
Steps involved in the process of writing and executing a program ................................. 26
Dry run on the algorithm of Fibonacci series. ................................................................. 28
Dry run on the algorithm of Fibonacci series. ................................................................. 28
Big-O notation ..................................................................................................................... 28
What is Big-O notation? .................................................................................................. 28
Python code to display the Fibonacci series .................................................................... 31
Python code to display the Factorial Value ..................................................................... 32
Activity 2 ................................................................................................................................. 33
what is Programming Paradigm ........................................................................................... 33
Imperative Programming (Procedural Programming) ..................................................... 33
Declarative Programming Paradigm ................................................................................ 34
Functional Programming Paradigm ................................................................................. 34
Object Oriented Programming ......................................................................................... 34
Event-driven Programming.............................................................................................. 34
Relationship among programming paradigms ................................................................. 35
Small snippets of code as example for the above three programming paradigms ........... 36
Small snippets of code for procedural programming paradigm....................................... 36
Small snippets of code for object-oriented programming paradigm ............................... 37
Small snippets of code for Event driven programming paradigm ................................... 38
Critically evaluating the snippets of code given as example for Procedural programming
.......................................................................................................................................... 39
Critically evaluating the snippets of code given as example for Object oriented
programming .................................................................................................................... 39
Critically evaluating the snippets of code given as example for Event-driven
programming .................................................................................................................... 40
Activity 3 ................................................................................................................................. 41

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 19


Suitable algorithms for vehicle tariff calculation for rents and hires................................... 41
Function 1: Rent calculation. ......................................................................................... 41
Function 2: Day tour - Hire calculation. ....................................................................... 42
Function 3: Long tour - Hire calculation. .................................................................... 43
Visual studio IDE (C#.net) Implementation of the above algorithms ............................. 44
Function 1: Rent calculation. ........................................................................................ 44
Function 2: Day tour - hire calculation. ....................................................................... 46
Function 3: Long tour - hire calculation. ..................................................................... 48
design of suitable database structure to store the tariffs for vehicle types and different
packages ........................................................................................................................... 51
Rent packages table in database ................................................................................... 51
Day tour hire packages table ........................................................................................ 52
Long tour hire packages ................................................................................................ 53
Rented vehicles table...................................................................................................... 54
Day tour hired table ....................................................................................................... 55
Long tour hired table ..................................................................................................... 56
Integrated Development Environment (IDE)................................................................... 57
Features of IDEs .............................................................................................................. 57
How these features in an Integrated Development Environment (IDE) help in application
development ..................................................................................................................... 58
Visual Studio IDE ............................................................................................................ 58
Using Visual Studios IDE vs not using an IDE. .............................................................. 59
Activity 4 ................................................................................................................................. 63
Designing and building a small system to calculate vehicle hire amounts and record them
in a database for customer billing and management reporting for Ayubo drive ................. 63
Login page....................................................................................................................... 63
Login page Code .............................................................................................................. 64
Login Page database ........................................................................................................ 64
Home page ...................................................................................................................... 65
Home page code ............................................................................................................... 66
Package Details Page ..................................................................................................... 67
Package Details Code ...................................................................................................... 68
Rent Packages Page ......................................................................................................... 69
Rent Packages code.......................................................................................................... 70
Hire Packages form........................................................................................................ 72

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 20


Hire Packages code .......................................................................................................... 73
Vehicle for rent page ........................................................................................................ 76
Day tour hiring page ...................................................................................................... 78
Long tour hiring form ...................................................................................................... 80
Test cases ......................................................................................................................... 82
The debugging process and the features available in Visual studio IDE for debugging ..... 91
The debugging process .................................................................................................... 91
Features available in Visual studios IDE to debug .......................................................... 92
Using the debugging process to develop more secure, robust application ...................... 94
Case 2 ............................................................................................................................... 95
Coding standards.............................................................................................................. 98
Purpose of Having Coding Standards .............................................................................. 98
Some common coding standards ..................................................................................... 98
The coding standards That I have used in my application development ....................... 100
Critically evaluating why a coding standard is necessary for the team as well as for the
individual ........................................................................................................................... 103
Advantages using of Coding standards. ......................................................................... 103
References ...................................................................................................................... 104

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 21


ACTIVITY 1

ALGORITHMS

What is an algorithm?

A technique or process used to solve a problem is known as a programming algorithm. It is


based on carrying out a series of predetermined actions that, when combined, indicate how to
carry out a task, and your computer will always carry out that task in that same manner. An
algorithm operates by following a set of input-based steps. It will see a result, sometimes
referred to as an output, when it has followed all the inputs.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 22


Figure 1 Algorithm

Characteristics of an algorithm.

 Unambiguous – algorithms must give only one meaning. Each of the steps must be
clear
 Independent – It should have step-by-step directions.
 Input – Algorithms should have inputs
 Output – It should have one or more outputs.
 Finiteness – Algorithms must stop eventually
 Effectiveness - It should be feasible with the available resources.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 23


Figure 2 - Characteristics of algrithm

Algorithms to display the Fibonacci series and the factorial value using
Pseudo code

Fibonacci series

The Fibonacci sequence is a collection of integers (the Fibonacci numbers) that goes from 0
to 1, then 1, then 1, then a series of numbers that increase continuously after that. Each
number in the series is equal to the sum of the two numbers before it.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 24


Algorithms to display the Fibonacci series using Pseudo code

Pseudocode for Fibonacci Series up to n numbers :-


Step-1 Start
Step-2 Input Value of n
Step-3 A=0, B=1, C=2
Step-4 Print A, B
Step-5 IF (c >n) then go to step 12
Step-6 I=A+B
Step-7 print I
Step-8 A=B
Step-9 B=I
Step-10 c=c + 1
Step-11 Go to step-4
Step-12 Stop

Algorithms to display the factorial value using Pseudo code

Pseudocode for Factorial of a number:


Step 1: Declare n and f as integer variable.
Step 2: Initialize f=1.
Step 2: Enter the value of n.
Step 3: Check whether n>0, if not then f=1.
Step 4: If yes then, f=f*n.
Step 5: Decrease the value of n by 1 .
Step 6: Repeat step 4 and 5 until n=0

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 25


Steps involved in the process of writing and executing a program

Steps Involved in Programming


1. Analyzing the Problem
2. Algorithm design / Pseudocode
3. Flowchart
4. Coding
5. Debugging
6. Testing
7. Final output
8. Documentation

9. Analyzing the Problem


This is the first step of programming and involves getting the following informationThese
things are very important for the programmer because it provides him the basis for planning
about the programming and to control the potential difficulties that may arise.

2. Algorithm Design
In this stage all the instructions which are to be perform at different stages are listed. These
are in simple English language. We may call it as a strategy.

3. Flowchart
It is a graphical tool that shows the steps/stages which are to be executed in a program. All
the steps which are written in the second stage are now presented in a diagrammatic manner
so as to make it easily understandable. Making of flowchart helps us in increasing our process
of program development because it facilitates us to define the logic, detecting and removing
errors in a program design.
Types of flow chart
 System Flowchart shows the processing of entire system. It describes the input/output
devices, the media being used and the flow of data in the system.
 Program flowchart shows the complete steps involved in the execution of a program
including I/O, processing, loops and branching. It is more detailed than system
flowchart.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 26


4. Coding
In this step programmer writes the instructions in a computer language to solve the problem.
All coding process depends upon the information we obtained in previous steps. Choice of
language depends upon the requirements and facilities available with a language.

5. Debugging
In this stage we remove all the errors in the program because when we are coding, there are
chances that some mistakes may occur at that time. Here the program is executed manually,
called DRY RUN. This is done several times until all the errors are removed from the
program and the system become errors less.

6. Testing
In this stage we test the program by entering dummy data (includes usual, unusual and invalid
data) to check the behavior and result of the program towards the given data.

7. Final Output
After going through all the above stages, the program is given the TRUE DATA. Here the
programmer expects the positive results of the program and expects full efficiency of the
program.

10. Documentation
Most of the programmer neglect this stage by giving many reasons, but this is very important
because this will help the programmer to correct the problems that may occur in the program.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 27


Dry run on the algorithm of Fibonacci series.

Step n A B I c Output
Initial 4 0 1 1 0 0
st
1 iteration 1 2 2 1 1
2nd iteration 2 3 3 2 1
3rd iteration 2 5 5 3 2
4th iteration 5 8 8 4 3

Dry run on the algorithm of Fibonacci series.

step n f
1 5 120

Big-O notation

What is Big-O notation?

From a programming concept, Big O notation is used as a sort of measurement unit that helps
programmers evaluate or estimate the efficiency of a written bloc of code, a script or an
algorithm: “What the amount of time it’s going to take to run? What is the complexity
depending on the variation of data to be processed by that piece of code”.

It’s hard to determine the exact runtime of a script or an algorithm. Which is also dependent
on other factors such as the speed of the processor and other specifications of the computer in
which that script or algorithm is running. So instead of evaluating the runtime directly, big O
notation is used to evaluate how quickly the runtime grows relative to the input data to be
processed by that algorithm.

Time complexity. The time complexity of an algorithm determines the number of steps taken
by the algorithm, measured with respect to n (input data to be processed), the size of the
input.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 28


Space complexity. The space complexity of an algorithm determines the amount of space
required by the algorithm to execute, measured with respect to n (input data to be processed).

Constant | O(1)
 Notice that in the scenario above, the pigeon would take the same amount of time to
carry 5KB, 10MB or 2TB of data stored in the USB drive. The pigeon will always
take the same amount of time to move any amount of data from office A to office B,
It just has to fly 50 miles — considering certain assumptions and simplifications of
course.
So in Big O Notation, the time the pigeon takes to move data from office A to office B is
referred to as constant time: O(1). Meaning the time is constant with respect to the size of the
input.

Linear | O(n)
 Whereas, transferring data over the internet would take longer and longer as the
amount of data to be transferred increase.
So in Big O Notation, the time the internet takes to transferred data from office A to Office B
will grow linearly and in direct proportion to the size of the input data set and represented
as O(n). with n being the amount of data to be transmitted.
In computer programming, Big O favors the worst-case performance scenario; meaning, for
example, a case where we are looking for a matching number in an array of number which
could be found during any iteration of the for loop and the function would return early. Big O
notation will always assume the upper limit where the algorithm will perform the maximum
number of iterations to find the matching number (if the number was the last element stored
in the array).

Quadratic | O( n²)
Quadratic or O(N²) represents an algorithm whose performance is directly proportional to the
square of the size of the input data set.
A nested iteration over the data set ( such as nest for loop) is a common example of a script or
algorithm that involve quadratic runtime. Thus, deeper nested iterations will result in O(N³),
O(N⁴), etc

Exponential | O(2^n)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 29


An algorithm is said to have an exponential time or O(2^n) if its runtime doubles with each
addition to the input data set. The growth curve of an O(2^n) function is exponential —
starting off very shallow, then rising meteorically. A recursive calculation of Fibonacci
numbers is one example of an O(2^n) function is:

Logarithmic| O(log n)
Logarithmic time complexity is a bit trickier to get at first. So I’m going to use a common
example to explain it: Binary search concept.
Binary search is a technique used to search sorted data sets. It works by selecting the middle
element of the data set and compares it against a target value. If the values match it will
return success. If the searched value is higher than the value of the probe element it will take
the upper half of the data set and perform the same operation against it.
otherwise, if the searched value is lower than the value of the probe element it will perform
the operation against the lower half. this set of actions will continue to halve the data set with
each iteration until the searched value has been found or until it can no longer split the data
set:

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 30


Python code to display the Fibonacci series

n = int(input("Number of terms? "))

A=0
B=1
C=0

if n <= 0:
print("Please enter a positive integer")

elif n == 1:
print("Fibonacci sequence upto",n,":")
print(A)

else:
print("Fibonacci sequence:")
while n > C:
print(A)
I=A+B
A=B
B=I
C += 1

Figure 3 - Pyhton code for fibonacci series

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 31


Python code to display the Factorial Value

num = int(input("Enter a number: "))

f=1
if num < 0:
print("Please enter a positive number")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
f = f*i
print("The factorial of",num,"is",f)

Figure 4 - Python cde to dispaly factorial

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 32


Activity 2

what is Programming Paradigm

A programming paradigm is a fundamental style of computer programming. Paradigms differ


in the concepts and methods used to represent the elements of a program (such as objects,
functions, variables, constraints). And also steps that comprise a computation (such as
assignations, evaluation, continuations, data flows).
Common Programming Paradigms are:
 Imperative Programming Paradigm
 Declarative Programming Paradigm
 Functional Programming Paradigm
 Object Oriented Programming Paradigm
 Event-driven Programming Paradigm

Imperative Programming (Procedural Programming)

Imperative programming is a programming paradigm that uses statements that change a


program’s state. In much the same way that the imperative mood in natural languages
expresses commands. An imperative program consists of commands for the computer
perform. Imperative programs describe the details of HOW (HOW means describing the
inputs and describing how the outputs are produced) the results are to be obtained.
Characteristics of Procedural Programming:
 Emphasis is on doing things (algorithms).
 Large programs are divided into smaller programs known as functions.
 Most of the functions share global data.
 Data move openly around the system from function to function.
 Functions transform data from one form to another.
Examples: C, C++, Java, PHP, Python, Ruby etc.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 33


Declarative Programming Paradigm
Declarative programming is a style of building the structure and elements of computer
programs that expresses the logic of a computation without describing its control flow.
Declarative programming focus on what the program should accomplish. Declarative
programming often considers programs as theories of a formal logic and computations as
deductions in that logic space.
Examples: SQL, XSQL (XMLSQL) etc.

Functional Programming Paradigm


Functional programming is a subset of declarative programming. Programs written using this
paradigm use functions, blocks of code intended to behave like mathematical functions.
Functional languages discourage changes in the value of variables throughassignment,
making great deal of use of recursion instead.
Examples: LISP, Haskell, Python, Ruby, JavaScript etc.

Object Oriented Programming


Object Oriented Programming (OOP) is a programming paradigm based on the concept of
“objects”, which may contain data, in the form of fields, often known as attributes: and code,
in the form of procedures, often known as methods.
There is significant diversity of OOP languages, but the most popular ones are classbased,
meaning that objects are instances of classes, which typically also determine their type. In
OOP, computer programs are designed by making them out of objects.
Key characteristic of OOP:
 Encapsulation – Capability to hide data and instructions inside an object.
 Polymorphism – The design of new classes is based on a single class.
 Inheritance – Ability to create one object from another.
 Message Passing – It is the way objects communicate with each other.
 Garbage Collection – Automatic memory management that destroys objects that
 are no longer in use by the program.
Examples: C++, C#, Java, PHP, Python

Event-driven Programming
Event-driven programming is a programming paradigm in which control flow of theprogram
is determined by the occurrence of events. For example a user action such as amouse click,
key press or a message from the operating system or another program.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 34


Key Features of Event-Driven Programming:
 Event loops – The event loops keeps testing the user interface to see if anything
 has happened (e.g. button click).
 GUI design (Forms and Controls) – Usually used for GUIs where many types of
 events are generated.
 Trigger functions – These are used along with the object’s name to determine
 with event handler to run.
 Event handlers – The event handlers are the actual program code modules that
 are executed when a particular trigger has occurred.
(techopedia, 2022)

Relationship among programming paradigms

These programming paradigms have many relationships. Such as


 Lot of languages will facilitate programming in oneor more paradigms.
 Some paradigms are very similar to other paradigms.
 Most of the paradigms are based on event driven and object oriented paradigms.
 Many of the paradigms are based on the problem to be solved there for it allows
 user to solve problems more efficiently.
 These three categories are not related strictly with hierarchically, but commonly
all
 of them are mostly nested within one another

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 35


Small snippets of code as example for the above three programming paradigms

Small snippets of code for procedural programming paradigm

#start
#to find the average of 3 numbers
#requsting user to insert the three numbers to input
x = int(input("Enter the first number: "))
y = int(input("Enter the second number: "))
z = int(input("Enter the third number: "))
#adding the three numbers
sum = x + y + z
#finding the average of the three numbers
avg = sum / 3
#displaying the numbers
print("first number: ", + x)
print("seocnd number: ", + y)
print("third number: ", + z)
#display the sum
print("sum of three numbers = ", + sum)
#display the average
print("Average = ", + avg)

Figure 5 - code for procedural programming

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 36


Small snippets of code for object-oriented programming paradigm

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Program p0 = new Program();
Console.WriteLine("Enter the first number: ");
int number1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the second number: ");
int number2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the third number: ");
int number3 = Convert.ToInt32(Console.ReadLine());
p0.averageNumbers(number1, number2, number3);
}
int averageNumbers(int x, int y, int z)
{
int sum = x + y + z;
int avg = sum / 3;
Console.WriteLine("The Average is = " + avg);
return avg;
}

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 37


Small snippets of code for Event driven programming paradigm

private void button1_Click(object sender, EventArgs e)


{
//to catch the username and password
string username = TxtUsernameLogin.Text;
string password = TxtPasswordLogin.Text;
//condition to grant access
if (username == "Admin" && password == "Admin123")
{
//if the username and password, access is granted
MessageBox.Show("Welcome!!!", "Login Success!",
MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
//redirecting to the next page
EmployeeDetails mm = new EmployeeDetails();
mm.Show();
}
else
{
// if username and passwords are wrong, an error message is shown
MessageBox.Show("Invalid usernaem or password! Please try
again", "Error", MessageBoxButtons.RetryCancel,
MessageBoxIcon.Error);

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 38


Critically evaluating the snippets of code given as example for Procedural
programming

In procedural programming, a problem is broken down in to smaller manageable parts. The


example code is to find the sum of 3 inputs numbers given by a user. Here, the first Step is to
get three inputs from users (x, y, z), then find the sum of all three numbers and finally find
the average by dividing the sum by 3. Then the outputs are the average, sum and the numbers
user has given as inputs.
As you can see, the problem is to find the average of three numbers, to get the required
output, the code is split in to four parts as shown above to make it manageable.

Critically evaluating the snippets of code given as example for Object oriented
programming

As shown in the code, I have made an instance named ‘averageNumbers’ to find the average
of 3 numbers. Inside this instance I have written a code to find the sum of the 3 numbers and
find the average by dividing it by 3. Then inside Main where the codes run, the user inputs
are asked for 3 variables. Then I call the instance ‘averageNumbers’
with the 3 inputs to find the average. In object oriented, we can make objects as above and
call them whenever necessary (we don’t have to write the whole code over and over again).
Here is another example,

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 39


void getAllDayData()
{
//to display all data from Hire_Day_Packages table n data grid view
//SqlCommand com = new SqlCommand("select from Hire_Day_Packages",
con);

Critically evaluating the snippets of code given as example for Event-driven


programming

In event-driven, as mentioned above, a program is executed after a user event like a mouse
click. The code I’ve given as an example is a code which gives a message “Welcome!” if the
user gives the correct username and password to login and “Invalid username or password” if
username or password is wrong. For this code to work, the user must insert the username and
password, then click login (mouse click and keyboard inputs).

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 40


Activity 3

Suitable algorithms for vehicle tariff calculation for rents and hires

Function 1: Rent calculation.

Function Rent_calculation
Step 01 - Get values of vehicle_type, Rented_date, Return_date, Driver_parameters

Step 02 - set total_rent, Total_days, no_of_months, remaining_days, no_of_weeks,


no_of_days, to zero

Step 03 - Calculate no of days (Total_days) = Return_date - Rented_date

Step 04 - no_of_months = Total_days / 30

Step 05 - remaining_days = Total_days - (no_of_months * 30)

Step 06 - no_of_weeks = remaining_days / 7

Step 07 - no_of_days = remaining_days - no_of_weeks * 7

Step 08 - get values of monthly_rates, weekly_rates, daily_rates, driver_cost from database

Step 09 - if driver_parameters = yes,

Step 10 - total_rent = (no_of_months * monthly_rates) + (no_of_weeks * weekly_rates) +


(no_of_days * daily_rates) + (Total_days * driver_cost)

Step 11 - else if driver_parameters = no,

Step 12 - total_rent = (no_of_months * monthly_rates) + (no_of_weeks * weekly_rates) +


(no_of_days * daily_rates)

Step 13 – end if

Step 14 - Display total_rent

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 41


Function 2: Day tour - Hire calculation.

Function Day_tour_Hire

Step 01 - Get values of Package_no, Package_type, Start_km, End_km, Start_time,End_time.


Step 02 - initialize total_hire_charge, Total_hours, extra_hours, Waiting_charges,
Total_distance, Extra_km to zero
Step 03 - Calculate Total_hours = End_time - Start_time
Step 04 - get values of package_rates, Max_km, Max_hour, Extra_km_rates,
Extra_hour_ratres
Step 05 - extra_hours = Total_hours - Max_hour
Step 06 - if extra_hours >= 1,
Step 07 - Waiting_charges = extra_hours * Extra_hour_ratres
Step 08 - else
Step 09 - Waiting_charges = 0
Step 10 – end if
Step 11 - Calculate Total_distance = End_km - Start_km
Step 12 - Extra_km = Total_distance - Max_km
Step 13 - if Extra_km >= 1,
Step 14 - Extra_km_charge = Extra_km * Extra_km_rates
Step 15 - else
Step 16 - Extra_km_charge = 0
Step 17 – end if
Step 18 - if (extra_hours >= 1 && Extra_km >= 1)
Step 19 - total_hire_charge = package_rates + Waiting_charges +
Extra_km_charge
Step 20 - else if (extra_hours >= 1)
Step 21 - total_hire_charge = package_rates + Waiting_charges
Step 22 - else if (Extra_km >= 1),
Step 23 - total_hire_charge = package_rates + Extra_km_charge
Step 24 - else
Step 25 - total_hire_charge = package_rates
Step 26 – end if

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 42


Function 3: Long tour - Hire calculation.

Function Long_tour_Hire

Step 01 - Get values of Package_no, Package_type, Start_km, End_km, Start_date,


End_date.
Step 02 - initialize total_hire_charge. Total_days, over_night_charges,
nparking_charges, extra_kms, to zero
Step 03 - Calculate Total_days = End_date - Start_date
Step 04 - get values of package_rates, Max_km, Extra_km_rates, OverNight_cost,
Night_parking_rates
Step 05 - if Total_days >= 2,
Step 06 - over_night_charges = Total_days * OverNight_cost
Step 07 - nparking_charges = Total_days * Night_parking_rates
Step 08 - end if
Step 09 - extra_kms = End_km - Start_km
Step 10 - if extra_kms >= 1,
Step 11 - extra_Km_charges = extra_kms * Extra_km_rates
Step 13 – end if
Step 14 - if Total_days >= 2 && extra_kms >= 1,
Step 15 - total_hire_charge = package_rates + over_night_charges +
nparking_charges + extra_Km_charges
Step 16 - else if Total_days >= 2
Step 17 - total_hire_charge = package_rates + over_night_charges +
nparking_charges
Step 18 - esle if extra_kms >= 1,
Step 19 - total_hire_charge = package_rates + extra_Km_charges
Step 20 - else
Step 21 - total_hire_charge = package_rates
Step 22 – end if
End Function

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 43


Visual studio IDE (C#.net) Implementation of the above algorithms

Function 1: Rent calculation.

When Driver parameter set yes

Figure 6 - When driver parameter set yes

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 44


Figure 7- when driver parameter set yes cont..

When Driver parameter set no

Figure 8 - when driver parameter set no

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 45


Figure 9 - when driver parameter set no cont

Function 2: Day tour - hire calculation.

Figure 10 - day tour algorithm1

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 46


Figure 11 – day tour algorithm 2

Figure 12 - day tour algorithm 3

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 47


Figure 13 - day tour algorithm 4

Function 3: Long tour - hire calculation.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 48


ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 49
ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 50
design of suitable database structure to store the tariffs for vehicle types and
different packages

Rent packages table in database

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 51


Day tour hire packages table

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 52


Long tour hire packages

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 53


Rented vehicles table

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 54


Day tour hired table

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 55


Long tour hired table

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 56


Integrated Development Environment (IDE)

Programmers can compose their code, organize text sections, and automate repetitive
programming tasks using an IDE. IDEs, as opposed to standard code editors, combine the
capabilities of various programming processes into a single process. IDEs allow for the
insertion of the use of frameworks and component libraries to expand upon the basic code.
The primary advantage of IDEs is their built-in debuggers, which enable programmers to
quickly and readily find flaws or errors when they are triggered. Additionally, it enables the
assignment of grouped codes and the creation of hierarchies by many programmers. The
groups can then be connected, compiled, and constructed.(techopedia, 2022)

Features of IDEs

 Text editor – Any IDE will have text editors which enables to write and
manipulate codes. Some IDEs have tools to drag and drop front-end components.

 Debugger – This feature allows programmers to identify errors and bugs within
the code and fix them with ease. It also allows them to test different parts of the
application find errors to fix them.

 Compiler – these translate programming language to machine readable language.


Machine codes are analyzed to ensure accuracy. Compilers can parse and
optimizes the code to optimize performance.

 Code completion – this feature allows helps programmers by identifying and


inserting common code components to complete the code. This saves time when
writing codes and reduces bugs.

 Programming language support – IDEs allow programmers to pick a


programming language. They offer many programming languages like Ruby,
Python, and Java IDE tools.

 Integrations and plugins – An IDE is a development portal, it incorporates all


your other development tools to improve workflows and productivity.
(Anon., n.d.)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 57


How these features in an Integrated Development Environment (IDE) help in
application development

 It serves as a single environment for most of the needs of a developer such as


 version control systems, debugging tools, and Platform-as-a-Service.
 Code completion capabilities can improve the workflow of programming.
 It automatically checks for errors and bugs to ensure top quality code
 Refactoring capabilities help programmers to make comprehensive and mistake
 free name changes.
 Maintain a smooth development cycle.
 Increase developer efficiency and satisfaction
 Deliver top-quality software on schedule

Visual Studio IDE

The Visual Studio IDE is a creative launching pad that allows programmers to edit, debug,
build code and publish them as a application. Compared to a code editor or any other IDEs
that provide standard editor and debugger, Visual Studios IDE provides compliers, code
completion tools, graphical designers, and many other features which helps programmers
with the development process.

Some other features available in The Visual Studio IDE.


 Squiggles and Quick Actions - Squiggles are wavy underlines. They tell you
abouterrors or problems in the code. They allow programmers to find and correct
errors without waiting to run the program to find errors. When you hover on the
Squiggle, you can see information about the error. A light bulb may appear in the left
margin with actions, known as Quick Actions, to fix the error.

 Code Cleanup - Code Cleanup format your code and apply any code fixes suggested
by your code style settings, editor config conventions, and Roslyn analyzers. (Note:
currently available for C# code only).

 Refactoring – This includes operations such as intelligent renaming of variables,


extracting one or more lines of code into a new method, changing the order of
method parameters, and more.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 58


 IntelliSense - This is a term for features that displays information about your code
directly in the editor and, in some cases, write small bits of code for you.
 Visual Studio search – This feature allows to rapidly find IDE features and code in
one place.

Using Visual Studios IDE vs not using an IDE.

Visual Studios IDE not using an IDE


This allows programmers to access databases This allows to write, edit codes only., which
or automatically write code to create a doesn’t save time.
graphical user interface (GUI) and also
suggested ways to complete strings of code
which save a lot of time.
When developing extensive development Difficult to develop complex projects.
projects, Visual studios IDE features like
debugging, Code completion, etc helps in
completing it with ease compared to normal
text editors.
Visual studios IDE built to eliminate things Text editors (non-IDEs) so not have these
that cause pauses in your workflow, you features.
don’t need to use the mouse because of the
shortcuts available.
When using languages like Java, IDEs are When using languages like PHP and Ruby,
much more effective. text editors are programmers choice.
Requires more space and memory. Requires less memory and space.
t is best to develop error free and secure Best to practice codes and requires more time
programs/ projects with less time due to the compared to IDEs.
available features.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 59


Here are a few examples on how using Visual studio IDE was better compared to not using
an IDE.
The features mentioned in ‘2022 Visual Studio IDE’ helped to save time and make an
application better compared to not using an IDE.

Example 1:
The code completion feature helped a lot to save time typing variable already declared and
calling names of tools to code.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 60


Example 2:

The tools available makes it much easier to build GUIs.

Example 3:

A simple code allows programmers to connect to a database to build the application.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 61


Example 4:
The text editor is user friendly as it shows where else a variable is assigned once clicked on
the variable.

Example 5:
Most errors are shown by a red line and once you hover on top of it, it shows the reason for
error as well which makes it much easier to find errors and debug before running the
program.

More uses of an IDE (debugging features) over not using an IDE are given under ‘Using the
debugging process to develop more secure, robust application’.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 62


Activity 4

Designing and building a small system to calculate vehicle hire


amounts and record them in a database for customer billing and
management reporting for Ayubo drive

Login page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 63


Login page Code

Login Page database

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 64


Home page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 65


Home page code

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 66


Package Details Page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 67


Package Details Code

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 68


Rent Packages Page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 69


Rent Packages code

Add

Delete

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 70


Update

Search

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 71


Hire Packages form

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 72


Hire Packages code

Add button code

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 73


Update button code

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 74


Delete button code

Search button code

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 75


Vehicle for rent page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 76


Rent a vehicle button code

Rent a vehicle delete button

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 77


Day tour hiring page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 78


Day tour – hire button

Day tour – delete button

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 79


Long tour hiring form

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 80


Long tour add button

Long tour delete button

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 81


Test cases

Test 1 - Login page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 82


Test 2 - Add a package

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 83


Test 3 - Update a package

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 84


Test 4 - Delete a package

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 85


Test 5 - Search a package

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 86


Test 6 - Check rates if driver = yes, Rent a vehicle page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 87


Test 7 - Check rates if driver = no, Rent a vehicle page

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 88


Rent a vehicle

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 89


Delete a rented vehicle record

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 90


The debugging process and the features available in Visual studio IDE
for debugging

The debugging process

The process of Identifying and fixing/ removing of existing and potential errors/ bugs in a
software code that can cause it to behave unexpectedly or crash is called debugging.
Debugging helps to prevent faults in an software by identifying the problem and fixing it.
(techopedia, 2022)

The debugging process contains to steps namely “fault localization”, “fault repair/ bug
fixing”. A programmer sometimes duplicates the problem in a software code to find the error
and find the cause then modify or delete the code to prevent it from happening again. Both
the first and second steps are time consuming and are difficult. The first step is more
important since to fix an error, the problem must be found. (techopedia, 2022)

According to the site “The Economic Times”, the steps in a debugging process are,
 “Reproduce the problem.
 “Describe the bug. Try to get as much input from the user to get the exact reason.”
 “Capture the program snapshot when the bug appears. Try to get all the variable
values and states of the program at that time”
 “Analyze the snapshot based on the state and action. Based on that try to find the
 cause of the bug.”
 “Fix the existing bug, but also check that any new bug does not occur”
(techopedia, 2022)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 91


Features available in Visual studios IDE to debug

There are many forms of debugging namely “Stepping through the code with a debugger”,
“investigating logs”, “unit testing”, “profiling”, and “analyzing dumps”. Visual studio
focuses on “interactive debugging”, which means “attaching to a running process with a
debugger, and investigating the program’s execution and state”.
Here are some features available in visual studios for debugging.

 Attaching the debugger: Once you press F5 or “select Debug | Start


Debugging”,debugging will automatically run in Visual studios.
 Debugger Break Mode: For debugging, the debugged process must be in “Break
Mode”. This means the program can be paused for a said line of code, and all
therunning threads are paused after a line of code. To get breaker mode, use “Debug|
Break All menu item” or place break points. To place breaker points, press F9, or
“Debug | Toggle Breakpoint”. Once a break point is set, the program will stop at that
point and start break mode.

 While in Break Mode – Navigate through code: when in break mode, it is possible to
you debug interactively and see the execution of codes. Some of the features of
navigation are,
“Continue (F5) will quit break mode and continue the program’s execution until the next
breakpoint is hit, entering break-mode again”.
“Step Over (F10) will execute the current line and break on the next line of code”
“Step Into (F11) is used when the next execution line is a method or a property. When
clicked, the debugger will step into the method’s code first line. By default, properties are
skipped. To enable stepping into property code, go to Tools | Options | Debugging and
uncheck Step over properties and operators”
“Run execution to here allows you to continue execution and break in a specified location
without a breakpoint. It’s like creating a breakpoint and removing it after first break. You
can do it in 3 ways,
Hover and click on the green arrow that appears on the start of each line and on the
desired line of code and click Ctrl + F10
Right click on the desired line of code and click on Set next statement
Run to a cursor location allows you to forcefully set the next line of code to execute.”
“The current (yellow) line will not be executed. It can be a line that was executed before
or after, but it’s best for the new line of code to stay in the current scope.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 92


There are 2 ways to do this:
1. Drag the yellow arrow to any line of code
2. Stand on the desired line of code and click Ctrl+Shift+F10”

Investigate variables: When In break mode you can see the values of variables and class
members. Hovering over the variable lets you this via a pop-up, this is called “Data tip”.
DataTip and QuickWatch notable Features: this has useful features such as, “Pinning
DataTips – You can leave a DataTip pinned to the editor by clicking on the pin icon.
Useful when you hit the same breakpoint many times (maybe in a loop)”
 Holding Ctrl will make the DataTip transparent by right clicking on an expression in
the DataTip, you can open a context menu with several options namely,
 Copy – Copies to clipboard both Expression and Value
(alex={DebuggingPillars.Person})
 Copy Expression – Copies expression (alex)
 Copy Value – Copies expression ({DebuggingPillars.Person})
 Edit Value – A useful feature where you can change the value during debugging.
Most useful for primitives (strings, integers, etc.)
 Add Watch – Adds expression to Watch window (more on that later)
 Add Parallel Watch – Adds expression to Parallel Watch window (more on that later)
 Make Object ID – Creates a scope-independent expression that starts with ‘$’ ($1, $2,
and so on). You can evaluate this expression at any time, regardless of the current
scope, in Quick Watch, Watch Window or the Immediate Window. A very useful
feature and can be used to detect memory leaks.

Breakpoint advanced features: There are lesser-know features of breakpoint. To see the
context menu for it, you can right click a break. A few examples are given bellow,
Conditions allows you to break on this breakpoint only when a condition is met.
Actions allow you to log a message to the output window whenever the breakpoint is hit. You
can continue execution, without stopping on the breakpoint.
Edit labels… allows to categorize breakpoints into labels. This makes it easier later to
organize them in the breakpoints tool window.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 93


Using the debugging process to develop more secure, robust application

Thanks to the features in Visual studios, it was easy to debug the application and make the
application a bug free secure application. As mentioned above, in the debugging process, the
most crucial part is “fault localization”. Using the “select Debug | Start Debugging”, I was
able to start debugging while running the application and find the errors in my application
and fix them. Here are a few instances as such,

Case 1

On the picture shown below, the variable ‘overnight’ is spelled in the coding but due the
debugger we could easily find the error of the codings.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 94


Case 2

In this case, the variable type for “nightpark” in the database was string and in the code was
double. I had to change the type in the database as float to fix the error after identifying it

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 95


Case 3

Here hoursOnly variable was an double and maxhours was a int. Thanks to the error message,
I was able to identify it and fix it by converting hours only to int by using the code ‘int
totalhours = Convert.ToInt32(hoursOnly);’.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 96


Case 4

Here the variable rendate was not declared instead it was rendte. I was able to avoid the error
when the red line showed and was able to fix it. These are some of the many instances that I
used the debugging process to debug the application to develop more secure, robust
application.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 97


Coding standards

Good Software Developers and development organizations maintain some well-defined and
standard style of coding called coding standards. Coding standards are made by organization/
programmer, depending on their needs, what suits their organization best and according to the
type of software developed. It is crucial to maintain coding standards because if coding
standards are not maintained, then the code maybe rejected during code review int the
organization.

Purpose of Having Coding Standards

 Coding standard gives a uniform appearance to the codes written by different


programmers.
 It reduces complexity and improves readability, and maintainability of the code.
 It helps in code reuse and helps to detect error easily.
 It increases efficiency of the programmers

Some common coding standards

 Limited use of global – This is about which types of data that can be declared global
and the data that can’t be.
 Standard headers for different modules – To understand and maintain the code in a
better way, 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

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 98


Naming conventions for local variables, global variables, constants and functions – Names of
variable should be meaningful and understandable as they help anyone to understand the
reason of using it. There are naming convections for local variable global variables, constants
and functions used by many programmers and organizations. Some of them are
 “Local variables should be named using camel case lettering starting with small letter
(e.g. localData) whereas Globalvariables names should start with a capital letter (e.g.
GlobalData). Constant names should be formed using capital letters only (e.g.
CONSDATA)”.
 “Avoiding the use of digits in variable names”
 “Names of function should be written in camel case starting with small letters”.
 “Name of functions should describe the reason of using of clearly and briefly.”

Indentation – To increase the code readability, proper indentation must be followed. Some
spacing/ indentation convections are,
 A space must be left 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.
 Coding style – A code should understandable. If the code is too complex, debugging
is difficult. Using coding styles that is too difficult to understand must be avoided.
 Do not using an identifier for multiple purposes - Descriptive and meaningful names
should be given for each variable that give the reason behind the name. If the same
variable name is used multiple times, it can lead to confusion and it would be difficult
to debug.
 Document codes – The codes should be properly documented in a way that is easy to
understand. Comments regarding the statements increase the understandability of the
code. (techopedia, 2022)

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 99


The coding standards That I have used in my application development

As any programmer, I have used some coding standards to code my application. Some of
them are given below with examples,
Standard 1: Naming conventions –
The naming convections I have used in coding are,
 For tools, I have named them in a way that it shows the page it belongs to as well as
the type of tool it is and every word has a capital letter in the first letter
(eg.waiting_charge_txt– this is the text box for Daily rates in rent packages page).
 For local variable I’ve used names that are understandable and follow a pattern (eg.
drates – daily rates, wrates – weekly rates).

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 100


Standard 2 : Indentation –

I have followed proper indentations and use of brackets for if else statements and others to
increase code readability and understandability.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 101


Standard 3: Coding style –

I have made sure to place comments on all codes to give a clear idea on what the code is and
why it is used.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 102


Critically evaluating why a coding standard is necessary for the team
as well as for the individual

Advantages using of Coding standards.

 They increase the efficiency of the software and reduces the development time.
 They help in identification of errors in an early stage.
 They increase readability and understandability of a code while reducing the
 complexity of the code.
 It reduces the hidden cost for developing the software. (techopedia, 2022)

When developing programs, it is necessary to think about time, cost, debugging and future
updates of it. Having certain standards when coding helps in those criteria. As mentioned
above, coding standards increase the efficiency and reduces the development time of a
software while helping us identify errors on an early stage. These standards also make the
code more readable and understandable, especially for other developers who might do future
updates or debug the errors that were not found initially. By making it easier to read,
understand and debug, the cost is reduced which effects the company, group or individual in
a positive way. Therefore, as mentioned above, having certain coding standards help save
time, cost and make it easier to debug.

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 103


References

[Online] Available at: https://medium.com/@bhattshlok12/characteristics-of-an-algorithm


[Accessed 20 12 2022].
[Online] Available at: https://www.csharp-console-examples.com/pseudocode
examples/pseudocode-to-calculate-factorial/ [Accessed 20 12 2022].
[Online] Available at:
https://www.tutorialspoint.com/learn_c_by_examples/fibonacci_non_recursive_program
_in_c.htm [Accessed 21 12 2022].
Anon., n.d. [Online] Available at: https://sciencerack.com/6-steps-of-program-development-
process-with
Anon., 2018. slideplayer.com. [Online] Available at:
https://www.bing.com/images/search?view=detailV2&ccid=0V8oQ89y&id=9D3FBC076886
9402D2BC8B6B2734F18A16D3B4B9&thid=OIP.0V8oQ89yG07wUnfcXLgAeQHaFj&med
iaurl=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fslideplayer.com%2F3306740%2F11%2Fimages%2F3%2 FBig O%
2Bnotation%2BUsed%2Bextensively%2Bto%2 [Accessed 23 12 2022].
Anon., 2018. SlideShare. [Online] Available at:
https://www.bing.com/images/search?view=detailV2&ccid=reca0pg%2F&id=692726BAA6
A0B9
5929E43CE33175FE0D9E13E663&thid=OIP.reca0pg_gg PLGD9iWxIuAHaEK&mediaurl
=https%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fimage.slidesharecdn.com%2F9-bigonotation 150305170945-
conversion-gate01%2F95%2F9-big-on [Accessed 17 june 2018]. Rouse, M., 2018. tech
target. [Online] Available at: https://searchsoftwarequality.techtarget.com [Accessed 23 12
2022].

ALIYAR MOHOMMED AADHIL UNIT1-POGRAMMING ASSIGNMENT 01 104

You might also like