Tải bản đầy đủ (.pdf) (17 trang)

Assignment 2 Procedural Programming (PROG102)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (2.6 MB, 17 trang )

ASSIGNMENT 2 FRONT SHEET
Qualification

BTEC Level 5 HND Diploma in Computing

Unit number and title

Prog102: Procedural Programming

Submission date

Date Received 1st submission

Re-submission Date

Date Received 2nd submission

Student Name

Bui Quang Minh

Class

GCD1104

Student ID

GCD210325

Assessor name


Phan Thanh Tra

Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature

Grading grid
P4

P5

M3

M4

D2


 Summative Feedback:

Grade:
Lecturer Signature:

 Resubmission Feedback:

Assessor Signature:

Date:



Table of Contents
I.

IMPLEMENTATION (P4, M3) .................................................................................................................................... 4

1.

2.

STRUCTURE OF PROGRAM .................................................................................................................................... 4
1.1

DECLARATION PART ....................................................................................................................................... 4

1.2

EXECUTABLE PART.......................................................................................................................................... 5

FUNCTIONS..................................................................................................................................................................

7

2.1 FUNCTION “checkIdExist”: ………..................................................................................................................... 7
2.2 FUNCTION “viewAll” ………………...................................................................................................................... 7
2.3 FUNCTION “maxGrade” and “minGrade” .................................................................................................... 8
2.4 FUNCTION “findSameGrade” ............................................................................................................................ 9

3.


IMPORTANT ALGORITHMS.................................................................................................................................

9

4.

PROGRAM RESULTS ................................................................................................................................................. 6

II. TESTING (P5,M4)............................................................................................................................................................. 12

1.

TESTING THE PROGRAM ........................................................................................................................................ 12

2. ANALYZE TEST RESULTS ...................................................................................................................................... 14
III. EVALUATION (D2) .....................................................................................................................................................

14

1.

PROGRAM...................................................................................................................................................................

14

2.

PROCEDURAL PROGRAMMING …....................................................................................................................

15



ASSIGNMENT 2
I. Implementation (P4,M3)
1. Structure of your program:
DECLARATION PART
1.Libraries

2.Function

3.Local variables (in main)


EXECUTABLE PART
1. Main function


2. Function definition


2. Explain functions:
Function “checkIdExist”
 This function is used to check if the teacher entered the ID that was typed
before. So, to make sure that there is no ID repeated.
 IDs[50] and i are parameters, currentId is a local variables.
 I create the for loop to check the ID which just entered with IDs[i] entered.
 If currentId == IDs[i] returns true, teacher has to enter again, and if it
returns false, the program continues.

It is used when entering the ID (To avoid repeating ID)


Function “viewAll”
 This function is used to view the list of student IDs and Grades.
 I create the for loop with printf() to repeat printing out one by one the
value of 2 arrays until the loop equals to the number of students that the
teacher entered.
 I used margin to make printing more accurate such as %.3f


It is used when teacher selects option 1 “view all student IDs and Grades”

Function “maxGrade” and “minGrade”
 These functions are used to find the highest grade and lowest grade.
 Firstly, I attach the first student to maxGrade and minGrade.
 Then, I use a for loop from student numbered 2 to student numbered n-1
to check, if it is true with the condition, I attach the student i information as
maxGrade and minGrade.

It is used when teacher selects option 2 “view the highest and lowest grade”


Function “findSameGrade”
 This function is used to find if there is a grade that is equal to the highest or
lowest grade depending on the options.
 I create a for loop to check every grade in the array compared to max and
min found before.
 If it is true, the program prints every ID it found out.

It is used when teacher selects option 3 and 4 “view all the IDs that having highest
and lowest grades”. Maxgrade and mingrade were saved and this function is used

to find the IDs having the same grades.

3. Important algorithms:
- When entering the number of students, IDs, grades, and options. Do while loop
is used to limit the value of them.
- In function “checkIdExist”, the current ID will be checked and compared to IDs
typed before. If they are the same, return true and if they are different, return
false.
- In function “maxGrade” and “minGrade”, the for loop is used to find the highest
and lowest grades, they are compared to every grade in array. If they find the
value, it will be assigned (max or min).


- In function “findSameGrade”, when the highest and lowest grades are found,
this function is used to find IDs having those grades. Every grade in array will be
compared to max and min, and then print them.

Program results
When the teacher runs the program, it requires him to enter number of students
on the screen and he has to enter ID and grade of every student.

When the teacher enters option 1, the program will display all the student IDs and
grades on the screen.


When the teacher enters option 2, the program will display the highest and
lowest grades

When the teacher enters option 3 and 4, the program will display student IDs
which have the highest and lowest grades.



II. Testing (P5,M4)
1. testing the program:
Test Test
Case Content
1 Enter
wrong
number of
students
(0->50)
2 Enter
wrong
choice (1>5)

Test
Data
Enter
numbers
> 50 and
<0

Expected

Actual Result

Pass/Fail

The
program

returns to
re-enter

Pass

Enter
choices
>5 and
<1

The
program
returns to
re-enter

Pass

3

Enter
duplicate
student ID
typed
before

Enter
duplicate
IDs
entered
before


The
program
returns to
re-enter

Pass

4

Enter
Enter
wrong
numbers
grade value >10 and
<0

The
program
returns to
re-enter

Pass


5

The
program
prints all

IDs and
Grades
typed
before
Check
Enter
The
highest and student program
lowest
IDs and
prints the
grades
Grades
highest
and then and
select
lowest
option 2 grades
typed

Pass

6

Check IDs
having
highest and
lowest
grades


Pass

7

Check
ending
program
Enter
decimal
number
when
entering
number of
students

6

8

8

Check
printing all
student
information

Enter
decimal
number


Enter 5
students
including
IDs and
Grades

Lowest
grade is
1 and
highest
one is 5

The
program
prints all
IDs with
highest
and
lowest
grades
Choose
The
option 5 program
stops
Enter 1.5 The
program
shows a
row of
something
and prints

wrong
value
Enter
The
11.1
program
runs

Pass

Pass
Fail

Fail


when
entering ID

unstable
and skips
entering
ID step

2. Analysing test results:
My program almost solves the basic program give by math teacher, but there are
some challenges that need to be noticed.
 I enter an integer when entering number of students, the program wants
me to enter again, but when I enter decumal numbers, there is a problem
here.

Solution: I will use isdigit() to check whether the number is an integer or
not.
 I enter an integer when entering IDs, the program wants me to enter again,
but when I enter decumal numbers, there is a problem here.
Solution: In my opinion, I will use a new function, it is round() to return the
nearest value.

III. Evaluation (D2)
1. Evaluate my program:
This program no longer has a syntactic or logical error after finishing the basic
procedure.
In essence, the current version will feature a full operation and stable framework
that all requirements.
User, can manage their student information through a single interface

2. Lesson learnt:
Before package the program, we have to make a plan step by step and we should
test it in many cases to find errors and fix them


3. Future improvement:
As I mentioned in analysing test results, I should check the program completely to
find the tiniest errors and fix them, I will add more algorithms and utilities to
make the program perfect.

4. Evaluate how procedural programming is applied to my program:
Pros







Cons



Adopted by many general-purpose programming languages.
Enhances the reusability of the code.
Makes the Implementation of algorithms easy.
Simplifies the code and makes it easy to understand.
Tracking the program flow is easy as the same flow linearly.
Data is vulnerable (if we declare lists of ID and grade, they are easy to
be accessed and modified by other functions).
Not much practical for solving real-world problems (Using lists of ID
and grade, we do not know the object of them. For example, we can
use struct).


Table of Contents
CHAPTER 1: INTRODUCTION TO YOUR PROGRAM (P3) .............................................................................. 5
I. CONTEXT OF THE PROBLEM ..................................................................................................................... 5
II. APPLICATION’S REQUIREMENTS ............................................................................................................. 5
CHAPTER 2: EXPLAIN PROGRAMMING PARADIGMS (P2) ........................................................................... 7
I. PROCEDURAL PROGRAMMING ................................................................................................................ 7
1. Definition ............................................................................................................................................. 7
2. Key Features ........................................................................................................................................ 7
2.1 Predefined functions ...................................................................................................................... 7
2.2 Local variable ................................................................................................................................. 7
2.3 Global variable ............................................................................................................................... 8

2.4 Modularity ..................................................................................................................................... 8
2.5 Parameter passing ......................................................................................................................... 9
II. OBJECT-ORIENTED PROGRAMMING ...................................................................................................... 9
1. Definition ............................................................................................................................................ 9
2. Concept .............................................................................................................................................. 10
III. EVENT-DRIVEN PROGRAMMING .......................................................................................................... 12
1. Definition ........................................................................................................................................... 12
2. Key Features ...................................................................................................................................... 12
2.1 Service oriented ........................................................................................................................... 12
2.2 Time driven .................................................................................................................................. 12
2.3 Event handlers ............................................................................................................................. 12
2.3 Trigger functions .......................................................................................................................... 13
2.3 Event ............................................................................................................................................ 13
3. Event-driven programming applications …........................................................................................ 13
IV. CONCLUSION ....................................................................................................................................... 14
V. EVALUATE THE SOURCE CODE (CODE STRUCTURE AND CHARACTERISTICS) ....................................... 15
CHAPTER 3: IDE FEATURES (P4-M2-M3-M4) ............................................................................................ 17
I. DEFINITION (P4) ………………………............................................................................................................ 17
II. IDE FEATURES (M2) ............................................................................................................................... 18
1. Syntax Highlighting ............................................................................................................................ 18
2. Autocomplete .................................................................................................................................... 19
3. Debugging .......................................................................................................................................... 20
4. Refactoring ........................................................................................................................................ 20
5. Code Search ....................................................................................................................................... 21
III. USING IDE TO MANAGE THE DEVELOPMENT PROCESS (M3) .............................................................. 21
IV. EXPLAINATION AND EVALUATION OF DEBUGGING PROCESS (P4-M4) ............................................... 23
1. Explaination of Debugging Process in the IDE used ........................................................................... 23
2. Evaluate how Debugging Process can be used to increase more secure .......................................... 24



2.1 Debugging process ....................................................................................................................... 24
2.2 Evaluation about debugging process ............................................................................................ 25
V. DEVELOPING APPLICATION USED IDE and ONE WITHOUT IDE (D3) ..................................................... 25
1. Evaluation of Developing Application using IDE ................................................................................ 25
2 Evaluation of Developing Application without using IDE .................................................................... 26
CHAPTER 4: DESIGN AND IMPLEMENTATION (P3-P5-D4) ......................................................................... 27
I. WRITE A PROGRAM ................................................................................................................................ 27
1. Flowchart ........................................................................................................................................... 27
1.1 Flowchart of application ............................................................................................................... 27
1.2 Flowchart of removing book ......................................................................................................... 28
1.2 Flowchart of removing client ........................................................................................................ 30
2. Source Code ....................................................................................................................................... 31
2.1 Removing book ............................................................................................................................. 31
2.2 Removing clinet ............................................................................................................................ 31
3. Screenshots ........................................................................................................................................ 32
3.1 Removing book ............................................................................................................................. 32
2.2 Removing client ............................................................................................................................ 33
II. EXPLAINATION and EVALUATION CODING STANDARD (P5) ................................................................. 33
1. Definition ........................................................................................................................................... 33
2. C# Coding Standard and Naming Convetions .................................................................................... 34
2.1 Pascal casing ................................................................................................................................. 34
2.2 Abbreviations ............................................................................................................................... 35
2.3 Vertically align .............................................................................................................................. 35
2.4 Comments .................................................................................................................................... 36
2.5 Set name for variables ................................................................................................................. 36
3. Coding Standard’s Advantages .......................................................................................................... 36
III. WHY CODING STANDARD IS NEEDED FOR TEAM AND INDIVIDUAL (D4) ............................................ 37
Reference list ……………………………………………………………………………………………………………………………………… 39




×