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

HUYNH TRAN ANH KHOA GCS200252 procedural

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 (1.44 MB, 48 trang )

1

• Assignment Brief 1 (RQF)
Higher National Certificate/Diploma in Computing
Unit Number and Title
Academic Year
Unit Tutor
Assignment Title

Unit 0: IT Fundamental & Procedural Programming
2021
Analysis and Design a solution for procedural programming
problem

Issue Date
Submission Date
IV Name & Date

Learning Outcomes and Assessment Criteria
Pass

Merit

Distinction

LO1 Understand the principles of procedural programming
LO2 Be able to design procedural programming solutions
P1 Provide an introduction to
procedural programming

M1 Discuss on characteristics


and features of procedural
programming

D1 Critically evaluate the
design of your solution
against the


2

P2 Identify the program units
and data and file structures
required to implement a
given design

M2 Review the design of a
procedural programming
solution.

characteristics and
features of procedural
programming.

P3. Design a procedural
programming solution for a
given problem

Assignment Brief
Scenario:
A math teacher wants to manage grades of a class. He asks you to help him to write a small

application to do that. He needs to enter student IDs, student’s grades and store these
information into 2 separate arrays (integer array for IDs and float array for grades). Then
he needs to print all student IDs together with their grades. Finally, he needs to know
which student has highest grade and lowest grade. Your program should be menu based
with the options above. When an option is done, the program should go back to the main
menu so he can choose another option. There should be an option to quit program.
Task 1
To prove your programming ability to be appointed to this small project, please prepare
an illustrated guide on programming in general and a particular emphasis on procedural
programming. Here you will need to include introduction to computer programming
languages and discuss key features of procedural programming.
Task 2
Your next task is to do the analysis for the scenario mentioned above by doing the
following subtasks
• Identify the variables and data types required in the program.


3





Identify and describe 2 different selection structures, including the condition(s) to
check; state why they are needed and where they can be used in the context of the
scenario.
Identify and describe any iteration constructs.
Split the program into functions (sub-functions) and draw a hierarchy diagram to
illustrate the structure of your program.


Task 3
You need to use a drawing tool to draw design diagram for your program, includes:
• A use case diagram for actions required
• Flow chart diagrams for: menu operation, printing IDs and grades, finding max
grade and finding min grade.
• Review / evaluate your design, state clearly pros vs cons and which needs to
improve, using characteristics of procedural programming as bases to discuss.
Write a report for 3 tasks above and submit the report to CMS in PDF format.

Submission Format
The 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.


4


5

Contents
• .......................................................................................................................................................................... Assignment Brief 1 (RQF)

1

Higher National Certificate/Diploma in Computing................................................................................................................................ 1
P1. Introduction to Procedural Programming: .......................................................................................................................................... 8
1. Introduction to Computer Programming Languages: ........................................................................................................................ 8

a. Definition: ........................................................................................................................................................................................ 8
b. Classification of Programming Languages: ................................................................................................................................... 9
c. Some Computer Programming Language ................................................................................................................................... 12
2. Definition of Procedural Programming: ........................................................................................................................................... 16
P2. Identify the program units, data and file structures: ......................................................................................................................... 17
1. Identify the variables and data types required in the program: ...................................................................................................... 17
2. Identify and describe 2 different selection structures:..................................................................................................................... 19
a. “Switch case” statement function: ................................................................................................................................................ 19
b. “If” statement function: .................................................................................................................................................................. 22
3. Data Type in Procedural Programming ( C Language ) ................................................................................................................ 23
a................................................................................................................................................................................ Integer Data Type

23

b................................................................................................................................................... Floating point type and Double type

24

c. .................................................................................................................................................................................... Character type

24

4. Iteration Structure............................................................................................................................................................................. 25
a........................................................................................................................................................................................... While Loop

25

b..................................................................................................................................................................................... Do-While Loop

26


c. ............................................................................................................................................................................................... For loop

27


6
P3. Design a procedural programming solution for a given problem..................................................................................................... 29
Flowchart .............................................................................................................................................................................................. 32
Conclusion ............................................................................................................................................................................................ 47
Reference ............................................................................................................................................................................................. 47


7


8

P1. Introduction to Procedural Programming:
1. Introduction to Computer Programming Languages:
a. Definition:
Programming language is a formal language of computer comprising a set of string that produce various kinds of
machine code. Programming languages are used in computer programming to implement algorithm by writing code


9

Figure 1 - Computer Programming Languages

b. Classification of Programming Languages:

- High-level languages:
It is a programming language with strong abstraction, which uses in advanced software. It may use natural language
elements, so the programmers are very easy to use or may automate significant areas of computer system. It makes
the process of developing a program simpler and more understandable when using a high-level language.
Examples: C, C++, JAVA, Python, ….


10

- Low-level languages:
It is the exact opposite of high-level language. Low-level language is a programming language with weak
abstraction or no abstraction. from a computer's instruction set architecture—commands or functions in the
language map that are structurally similar to processor's instructions. Because of the low abstraction between the
language and machine language, its usage is quite complicated and difficult to use. Programs of low-level languages
are relatively non-portable, because it is optimized for a certain type of system architecture.
Examples: Assembly Language, Machine Language, …


11

Figure 2 - High-level & Low-level Languages


12

c. Some Computer Programming Language

Figure 3: C Language



13

Figure 4: Java Language


14

Figure 5: Python Language


15

Figure 6: Machine Language


16

2. Definition of Procedural Programming:
Procedural Programming is a programming clay model that uses a linear or top-down approach. It depends on
procedures or syllabus to perform maths. Procedural Programming is also known as instruction programming.
The main purpose of Procedural Programming is the division of programming duties into a set of variables, data
structures, and subroutines. In object-oriented programming, it breaks down a programming task into objects that
expose behavior and data using interfaces

Figure 7: Procedural Programming


17

P2. Identify the program units, data and file structures:

1. Identify the variables and data types required in the program:
Variable’s name

Data type

grades[50]

float

IDs[50]

int

max/min

float

Explanation
-It performances grade of
students
-I choose float because it
includes real number of
speeds
-It shows ID of students
-I choose int because it
consists of only integers
-It declares the highest and
lowest grade
-I choose float because it
includes both integers and

real numbers


18

MaxID,MinID

int

choice

int

i, j

int

n

int

-It shows serial number of
students who has the highest
and lowest grade
-I choose int because it
consists of integers only
-It reports option that user
chooses.
-I choose int because ut
consist of integers

- They are used in loop
function and be numeral
number in array function.
- I choose int because it can
only be integers.
- It declares the total numbers
of students
- I choose int because it
cannot be real numbers.

Tables 1: Table of variables

A variable is a mutable quantity used to solve equation problems. We usually use a single letter to represent a
variable. The letters x, y, and z are common generic symbols used for variables. In computer programming, a
variable or directionless is a storage location paired with a related characteristic name, which stores some known or


19

unknown amounts of information, it is called a value or in easy terms, a variable is a container for different types of
data.
The variable name is the popular way to reference the stored value, in addition to referring to the variable itself,
depending on the context. Format computer source code associated with a run-time value and the value of that
variable can change during of program execution.
Example: The preceding program creates two variables, with the name a and h

Figure 8: Create two variables with name a and h

2. Identify and describe 2 different selection structures:
a. “Switch case” statement function:

• It is used where the expression is evaluated results in multiple values. And in my report, I


20

use it to create multiple options which users choose to report and use in “Menu options”. Option 2 is to print all
information on the screen.


21


22

Figure 9: Code Example of “Switch case”

With this function, my program can have a lot of function for users need to do with their information, such as finding
the highest mark or lowest grade and which student has that

b. “If” statement function:
It allows us to do conditional problems or make decision in the program. Moreover, it lets program to test conditions
and make decision about which code block to be executed. In my program, “if” statement is used to find the highest
and lowest grade in memory that users have already entered.
Example:

Figure 10: Code example of “if”

In this example, max is known as the highest grade that we need to find out. If max is lower than one element, max
will get new value and this new value is equal to that element



23

3. Data Type in Procedural Programming ( C Language )
Each variable in C has a corresponding data type. Each data type necessitates a different amount of memory and has
its own set of operations that can be performed on it. Let us go through them one by one

a. Integer Data Type
Here are some common integer data types


24

b. Floating point type and Double type
Floating point and Double Type are used to keep as archives decimal number (number with floating point value)
with single and double precision

c. Character type
The most foundation data type in C In almost all compilers, it stores a single character and requires a single byte of
memory.


25

4. Iteration Structure
a. While Loop
While loop is also known as a pre-tested loop. Summarize, while loop allows a part of the code to be executed
multiple times depending upon a given boolean condition. It can be viewed as a repeating if statement. The while
loop is mostly used in the case where the number of iterations is not known in advance.



×