1. Trang chủ
  2. » Công Nghệ Thông Tin

Assignment 2 Procedural Programming (PROG102)

17 22 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Assignment 2 Procedural Programming
Tác giả Bui Quang Minh
Người hướng dẫn Phan Thanh Tra
Trường học Btec
Chuyên ngành Computing
Thể loại assignment
Định dạng
Số trang 17
Dung lượng 2,6 MB

Nội dung

Môn học này đóng vai trò quan trọng trong việc cung cấp cho người học sự hiểu biết sâu rộng về các nguyên tắc cơ bản trong lĩnh vực Công nghệ Thông tin (CNTT) và Lập trình. Những kiến thức được truyền đạt trong khóa học không chỉ là nền tảng vững chắc cho việc tiếp cận và hiểu rõ sâu sắc về CNTT mà còn giúp học viên phát triển kỹ năng lập trình đặc biệt.

Trang 1

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Prog102: Procedural Programming

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

Trang 2

 Summative Feedback:  Resubmission Feedback:

Lecturer Signature:

Trang 3

Table of Contents

I IMPLEMENTATION (P4, M3) 4

1 STRUCTURE OF PROGRAM 4

1.1 DECLARATION PART 4

1.2 EXECUTABLE PART 5

2 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

Trang 4

ASSIGNMENT 2

I Implementation (P4,M3)

1 Structure of your program:

DECLARATION PART 1.Libraries

2.Function

3.Local variables (in main)

Trang 5

EXECUTABLE PART

1 Main function

Trang 6

2 Function definition

Trang 7

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

Trang 8

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”

Trang 9

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)

Trang 10

- 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

Trang 11

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

Trang 12

II Testing (P5,M4)

1 testing the program:

Test

Case Test Content Test Data Expected Actual Result Pass/Fail

1 Enter

wrong

number of

students

(0->50)

Enter numbers

> 50 and

< 0

The program returns to re-enter

Pass

2 Enter

wrong

choice

(1->5)

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

wrong

grade value

Enter numbers

>10 and

<0

The program returns to re-enter

Pass

Trang 13

5 Check

printing all

student

information

Enter 5 students including IDs and Grades

The program prints all IDs and Grades typed before

Pass

6 Check

highest and

lowest

grades

Enter student IDs and Grades and then select option 2

The program prints the highest and lowest grades typed

Pass

6 Check IDs

having

highest and

lowest

grades

Lowest grade is

1 and highest one is 5

The program prints all IDs with highest and lowest grades

Pass

7 Check

ending

program

Choose option 5 The program

stops

Pass

8 Enter

decimal

number

when

entering

number of

students

Enter 1.5 The

program shows a row of something and prints wrong value

Fail

8 Enter

decimal

number

Enter 11.1 The program

runs

Fail

Trang 14

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

Trang 15

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

 Enhances the reusability of the code

 Tracking the program flow is easy as the same flow linearly

Cons

 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)

Trang 16

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

Trang 17

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

Ngày đăng: 02/02/2024, 09:46

TỪ KHÓA LIÊN QUAN

w