Docsity

Understanding Programming Paradigms: Procedural, Object-oriented, and Event-driven, Essays (university) of Information Technology

Partial preview of the text

Download Understanding Programming Paradigms: Procedural, Object-oriented, and Event-driven and more Essays (university) Information Technology in PDF only on Docsity!

BTEC FPT INTERNATIONAL COLLEGE

INFORMATION TECHNOLOGY

ASSIGNMENT 1

UNIT: PROGRAMMING

STUDENT : NGUYEN THI TUYET NHUNG

CLASS : IT

STUDENT ID : BDAF

SUPERVISOR : NGUYEN HOANG ANH VU

DaNang, June 2021

ASSIGNMENT 1 FRONT SHEET Qualification BTEC Level 4 HND Diploma in Business Unit number and title Unit: Programming Submission date 05/07/ Date received (1st sub- mission) Re-submission date Date received (2nd submission) Student name Nguyen Thi Tuyet Nhung Student ID BDAF Class IT16102 Assessor name Nguyen Hoang Anh Vu Student declaration I certify that the assignment submission is entirely my own work and I fully understand the con- sequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature: TUYETNHUNG Grading grid P1 P2 P3 P4 M1 M2 D1 D

ii

TABLE OF CONTENT

Contents TABLE OF CONTENT .............................................................................................. ii LIST OF TABLES AND FIGURES .......................................................................... iv LIST OF ACRONYM ................................................................................................ vi INTRODUCTION ...................................................................................................... 1 CHAPTER 1 ALGORITHMS, ISSUES RELATED TO ALGORITHMS AND BASIC PROGRAMMING………………….. ...................................................................................... 2 Provide a definition of what an algorithm is and outline the process in building an application. (P1) .......................................................................................................... 2 1.1 Algorithm definition .................................................................................... 2 1.2 Algorithm demonstration............................................................................ 4 1.2.1 Natural language…………………………………………………………….. 4 1.2.2 Flowchart or block diagram…………………………………………………. 7 1.2.3 How to create a good algorithm?........................................................... 10 1.3 Application building process .................................................................... 12 Determine the steps taken from writing code to execution. (M1) ................ 14 CHAPTER 2 PROBLEMS RELATED TO PROGRAMMING METHODS AND IDE………………………………..................................................................................... ..... 21 Give explanations of what procedural, object-oriented and event-driven paradigms are; their characteristics and the relationship between them. (P2) ............... 21 1.1 Definition of programming models ........................................................... 21 1.1.1 Procedural Programming……………...….………………………………. 15 1.1.2 Object-oriented Programming………………….…………………………. 1.1.3 Event-driven Programming……………...………………………………... 19 1.2 Characteristics of programming models .................................................. 27

iii

v Figure 22: Assembly language .......................................................................................... 16 Figure 23: High-level programming language .................................................................... 16 Figure 24: Compilation process ......................................................................................... 17

vi

LIST OF ACRONYM

RAM Random Access Memory GUI Graphical User Interface IDE Integrated Development Environment CPU Central Processing Unit DOS Disk Operating System OOP Object-Oriented Programming

Perfomed Student: Nguyen Thi Tuyet Nhung 2

CHAPTER 1 ALGORITHMS, ISSUES RELATED TO ALGORITHMS

AND BASIC PROGRAMMING

LO1 Define basic algorithms to carry out an operation and outline the

process of programming an application.

Provide a definition of what an algorithm is and outline the process in

building an application. (P1)

1.1 Algorithm definition An algorithm is a set of instructions designed to perform a selected task. This can be an easy process like multiplying two numbers or a complex process like playing a compressed video file. Search engines use proprietary algorithms to display the foremost relevant results from their search index for specific queries. An algorithm can be expressed within a finite amount of space and time, and in a well- defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state. [1] Example: tooth brushing algorithm.  Step 1: rinse mouth first with clean water to remove food particles. Figure 1. Brushing tooth algorithm example

Perfomed Student: Nguyen Thi Tuyet Nhung 3  Step 2: rinse the brush and take an appropriate amount of toothpaste. Figure 2. Brushing tooth algorithm example  Step 3: start brushing your teeth. Position the brush at a 45-degree angle to the jaw arch, brush in a circular motion along the length of the teeth, continuously until the entire outer surface of the jaw is covered. Bring the brush to the inner surface of the tooth, brushing the same way as the outside. The front incisors, place the brush vertically, tilt the brush head and bring it to the inside of the upper jaw, perform an up - down movement to brush the upper incisors. Do the same with the bottom teeth. Place the bristles in contact with the chewing surfaces of the teeth on either side, brushing from front to back. Figure 3. Brushing tooth algorithm example

Perfomed Student: Nguyen Thi Tuyet Nhung 5 to have background knowledge. Disadvantages: verbose; does not highlight the structure of the algorithm; difficult to perform with complex problems. Example: implement a natural language algorithm to make bread. To make this work, I need input data which is the baking ingredients (such as flour, water, butter, etc.), the oven, the baking tools (such as a knife, etc.). Here is the algorithm:  Step 1: prepare the ingredients and measure the proportions of the ingredients. Ingredients include: flour, yeast, water. Figure 6. Example of bread making process  Step 2: knead the dough. Add the ingredients and seasoning to the dough, knead the dough for 5-6 minutes. Figure 7. Example of bread making process

Perfomed Student: Nguyen Thi Tuyet Nhung 6  Step 3: divide the dough into portions. Figure 8. Example of bread making process  Step 4: rolling the dough. Figure 9. Example of bread making process  Step 5: steady dough fermentation to finish. Figure 10. Example of bread making process

Perfomed Student: Nguyen Thi Tuyet Nhung 8

NUMERICAL

ORDER

SYMBOL MEANING

1 Input 2 Process 3 Output 4 Decision 5 Flow line 6 Begin or End 7 Connector Table 1. Flowchart Explain more:

  • Input symbol: this is the input step. To process any job, we need input data to be able to process it.
  • Process symbol: this is the processing step of the algorithm; a shape is usually used to represent only one processing step.

Perfomed Student: Nguyen Thi Tuyet Nhung 9

  • Output symbol: indicates where information should be displayed in a process.
  • Decision symbol: indicates a question that needs to be answered yes/no or true/false. The flowchart path can then split into different branches depending on the answer or subsequent consequences.
  • Flow line symbol: it is used to denote move to next step if next step is true/false condition or no condition.
  • Begin or End symbol: this is the starting or ending point of an algorithm. The content inside it is usually "begin" or "end".
  • Connector symbol: usually used within more complex charts, this symbol connects separate elements across one page. Example: find max 2 numbers a and b. If the condition a is greater than b true then a max, otherwise if the condition is false then b max and terminate. Figure 13. Algorithm to find max 2 numbers a and b Example: implement the conversion algorithm from VND to USD. If VND is less than 0, then in this case, use the rhombus to repeat printing out VND numbers greater than 0. Know that VND is entered from the keyboard.

Perfomed Student: Nguyen Thi Tuyet Nhung 11 Figure 15. Algorithm to solve quadratic equation SOURCE-CODE:

Perfomed Student: Nguyen Thi Tuyet Nhung 12 1.3 Application building process Figure 16. Application building process