ASSIGNMENT 1 Procedural Programming, Assignments of Computer Science

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 progr

Typology: Assignments

2020/2021

Uploaded on 03/26/2021

trantuan
trantuan 🇻🇳

4.9

(32)

2 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 0: Procedural Programming
Submission date
05/03/2021
Date Received 1st
submission
Re-submission Date
09/03/2021
Date Received 2nd
submission
Student Name
Tran Minh Quan
Student ID
GCH200753
Class
GCH0905
Assessor name
Nguyen Dinh Tran Long
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
Quan
Grading grid
P1
P2
P3
M1
M2
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download ASSIGNMENT 1 Procedural Programming and more Assignments Computer Science in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 0 : Procedural Programming

Submission date 05/03/2021 Date Received 1st submission

Re-submission Date 09/03/2021 Date Received 2nd submission

Student Name Tran Minh Quan Student ID GCH

Class GCH0905 Assessor name Nguyen Dinh Tran Long

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 Quan

Grading grid

P1 P2 P3 M1 M2 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • P1. Introduction to Procedural Programming:
      1. Introduction to Computer Programming Languages:..............................................................................
      • a. Definition:
      • b. Classification of Programming Languages:
      • c. Some Computer Programming Languages:
      1. Definition of Procedural Programming:
  • P2. Identify the program units, data and file structures:
      1. Identify the variables and data types required in the program:
      1. Identify and describe 2 different selection structures:
      • a. “Switch case” statement function:
      • b. “If” statement function:
      1. Identify and describe iteration constructs:
      • a. “For” loop syntax:
      • b. “Do… while” and “while” statement:
      • c. Hierarchy diagram:
  • P3. Design:
      1. Use case diagram for actions required:................................................................................................
      1. Flowcharts:
  • Bibliography
  • Figure 1 - Computer Programming Languages Table of Figures
  • Figure 2 - High-level & Low-level Languages
  • Figure 3 - C Language
  • Figure 4 - Java Language
  • Figure 5 - Python Language
  • Figure 6 - Procedural Programming
  • Figure 9 - Code example of “Switch case”
  • Figure 10 - Code example of “If”
  • Figure 11 - Code example of “For”
  • Figure 12 - Code example of "Do... while"
  • Figure 13 - Code example of "While"
  • Table 1 - Table of Variables Table of Tables
  • Diagram 1 - Hierarchy Diagram Table of Diagrams
  • Diagram 2 - Use case Diagram.....................................................................................................................
  • Diagram 3 - Menu Flowchart
  • Diagram 4 – Display student’s information Flowchart
  • Diagram 5 - Find highest grade Flowchart
  • Diagram 6 - Find lowest grade Flowchart

P1. Introduction to Procedural Programming:

  1. Introduction to Computer Programming Languages:

a. Definition:

To writing guideline for computer to run one or more tasks, computer Programming

Languages is known as special languages designed for programmers. It defines a set of coding

rules so that can help programmers to create guidelines for carry out computer tasks. Different

programming languages have their own rules. (Anon., 2021)

Figure 1 - Computer Programming Languages

b. Classification of Programming Languages:

  • High-level Languages:

It is the programming language with powerful abstraction which gets from software

information. When the programmers use these applications, they can generate the program

without permission of detailed layout of the particular machine which runs its program.

It means that the programmers do not need to study computer design and take notice of

solving the problems. Due to this, they are also called Problem-Oriented Languages.

Examples: C, C++, JAVA,… (Anon., 2009)

  • Low-level Languages:

It is the programming language with non-powerful abstraction. The programmers need to

study carefully about computer design due to deep understanding of computer layout that for

composing the program for such a computer. Not like High-level Languages, the Low-level

Languages programs are only for one main computer. As a result, Low-level Languages is

less popular than High-level Languages.

Examples: Assembly Language, Machine Language,… (Anon., 2009)

Figure 4 - Java Language

Figure 5 - Python Language

  1. Definition of Procedural Programming:

Procedural Programming will split a program into smaller procedural blocks when each block has

its own private data and logic. The procedurals do not work jointly, they are independent and the

information will be exchange through arguments and return values.

Procedural Programming goes with definition of functions, procedurals, parameters and

arguments,…

Programmers can observe a program obviously through its functions in spite of any details. It is

extremely important as it will help solving serious problems become more easily and exactly.

(Tanaka, 2012)

Figure 6 - Procedural Programming

Figure 7 - Code example of “Switch case”

With this function, my program can have more functions that users need to do with their

information, such as finding the highest mark and who has that.

b. “If” statement function:

  • It allows us to make a 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 or the lowest mark in memory that users have already inputted.

  • Example:

Figure 8 - Code example of “If”

In this example, min is known as the lowest mark that we need to find out. If min is higher

than one element (the condition is true), min will get a new value and this new value is equal

to that element.

  1. Identify and describe iteration constructs:

a. “For” loop syntax:

  • This function will let program do the same thing in repeat with certain condition. If condition

is true, the program will continue and it only stops if condition is false.

  • In my program, this function helps me in the task of finding out the highest or lowest mark.

Due to this, we can compare “max”, “min” with every element in memory.

Figure 9 - Code example of “For”

In this example, we compare “min” with each element grades in array and we will get the

lowest value of grade, which is known as min, after this function.

b. “Do… while” and “while” statement:

  • They are two different kinds of iteration constructs. However, their work is based on the

same principle, which is repeated many actions with one condition. With them, program will

re-do the actions again and again until the condition returns false. However, the order of their

taking steps run differently.

  • To be more details, in “Do… while” statement, program will do the actions first before

checking the condition. Otherwise, the condition will be checked first then do the actions in

“While” statement.

  • If the program receives right condition in the first step, it will return the same value or result

in both statements “Do… While” and “While”. However, we will clearly see the different

between these two, if we give wrong condition in the first implementation. Truly, with

“While” statement, program will not do anything and exits immediately. But in “Do…

while”, program still does the given actions one time then break to exit iteration constructs.

  • Totally, with these two statements, I can persuade my program to get right type data from

users and do variety of actions until getting right information.

Figure 10 - Code example of "Do... while"

In this example, “Do… while” statement persuades users enter input number of students. If

users enter a character, the condition is true (Checknum(n) is function that checks input as

an integer and this condition is check input as not an integer) and this statement still happens.

It means that users have to enter input again and again until their input is an integer.

P3. Design:

  1. Use case diagram for actions required:

Diagram 2 - Use case Diagram

  1. Flowcharts:

Diagram 3 - Menu Flowchart

Diagram 5 - Find highest grade Flowchart

Step 1: Start.

Step 2: Declare float grades[50], int IDs[50], i, maxID, max.

Step 3: Check the condition “i < n”:

  • If false, print max to the screen.
  • If true, go to step 4.

Step 4: Check the condition “max < grades[i]”:

  • If true, set max = grades[i] and go to step 5.
  • If false, go straight to step 5.

Step 5: Increment i by +1 then repeat step 3.

Step 6: End.

Diagram 6 - Find lowest grade Flowchart

Step 1: Start.

Step 2: Declare float grades[50], int IDs[50], i, minID, min.

Step 3: Check the condition “i < n”:

  • If false, print min to the screen.
  • If true, go to step 4.

Step 4: Check the condition “min > grades[i]”:

  • If true, set min = grades[i] and go to step 5.
  • If false, go straight to step 5.

Step 5: Increment i by +1 then repeat step 3.

Step 6: End.