Assignment 1 brief (PROG102), Assignments of Programming Languages

This AS was got an DISTINTION GRADE.

Typology: Assignments

2020/2021

Uploaded on 02/15/2022

gac-mai
gac-mai 🇻🇳

5

(3)

3 documents

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Assignment Brief 1 (RQF)
Higher National Certificate/Diploma in Computing
Unit Number and Title
Unit 0: IT Fundamental & Procedural Programming
Academic Year
2021
Unit Tutor
Ho Nguyen Phu Bao
Assignment Title
Analysis and Design a solution for procedural programming
problem
Issue Date
Submission Date
IV Name & Date
Vo Minh Tri
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
characteristics and
features of procedural
programming.
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.
P3. Design a procedural
programming solution for a
given problem
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Assignment 1 brief (PROG102) and more Assignments Programming Languages in PDF only on Docsity!

Assignment Brief 1 (RQF)

Higher National Certificate/Diploma in Computing

Unit Number and Title Unit 0: IT Fundamental & Procedural Programming Academic Year 2021 Unit Tutor Ho Nguyen Phu Bao Assignment Title Analysis and Design a solution for procedural programming problem Issue Date Submission Date IV Name & Date Vo Minh Tri 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 D 1 Critically evaluate the design of your solution against the characteristics and features of procedural programming. 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. 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.
  • 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.

Table Of Figure

Figure 1 - Programming Language ........................................................................................... 3 Figure 2-ENIAC..................................................................................................................... 4 Figure 3 - Programming Languages Ranking (Source: www.tiobe.com) ........................................ 4 Figure 4 - Code Python ........................................................................................................... 5 Figure 5- Example of Procedural Programming ......................................................................... 5 Figure 6- Hello Word in C language ......................................................................................... 6 Figure 7- Global Variable and Local Variable ........................................................................... 7 Figure 8- Another Libraries ..................................................................................................... 7 Figure 9 - : Data types in C language (Mishra, 2021).................................................................. 9 Figure 10 - Variables and Data types in this program ............................................................... 10 Figure 11 - Example for using "if" statement function ............................................................. 10 Figure 12 - Example of using "if-else" statement functio.......................................................... 11 Figure 13 - Hierarchy diagram program ............................................................................. 12 Figure 14 - Example of using "switch case" statement function ......................................... 13 Figure 15 - Example of using "for" statement function ....................................................... 14 Figure 16 - Example of using "Do-while" statement function ............................................. 15

Table Of Diagram

Diagram 1 - Use Case Diagram .............................................................................................. 16 Diagram 2- Input Students ..................................................................................................... 17 Diagram 3 - Menu control ...................................................................................................... 18 Diagram 4-Student Rankings ................................................................................................. 19 Diagram 5-Find Max Grade ................................................................................................... 20 Diagram 6- Find Min Grade .................................................................................................. 21

Introduction

This is the first time I doing an assignment but I will try my best to get an M grade. With the development of social, nowadays, the application of technology is becoming more and more popular. Therefore, it requires students of information technology to improve their knowledge even more. However, to build a solid house, you need a solid foundation. That's why Procedural Programming (PROG102) is a very important subject for an information technology student like me. This course has helped me to understand more deeply about the components of the computer such as CPU, RAM, ROM; Learn more about system numbers like Octal, Hexadecimal and how to convert between system numbers. Also, I know more about how an operating system works. The most special is the C programming language. Although it is an old language, it has helped me understand the steps to solve problems, the syntax, and loops in programming, ... Here It's a huge step for me to learn more about programming in the future. In assignment, I will perform 3 chapter

Chapter 1: I will introduce programming languages, procedural programming. And the main functions of procedural programming. Chapter 2: I will present the libraries, variables, statements, and loops that I plan to use in the program and explain how I intend to use them. Chapter 3: I will present the flowchart, work breakdown structure and use case diagram I will use in the program about interpreting them with Pseudo code. Chapter 1: Procedural Programming and Programming Languages (P1, M1) 1.1 What is Programming Language? From time immemorial, when humans first appeared on earth, they created language to communicate with each other. Language is used to express one's meaning and feelings towards others, through which people understand each other. As people developed, they also began to create languages that were not used for normal communication, but a way for them to "communicate" with computers. Programming language is a tool we use to create a program for the computer so that the computer follows instructions and produces the results that the programmer wants. The computer will process the programming language in binary form and output the result in the same form. Programming languages will help us translate from binary code to an output that we humans can understand. A programming language is made up of lots of statements, loops, functions, strings, arrays, external libraries and symbols that act as connectors that allow humans to translate our thoughts into instructions that the computer can understand. (Team, 2021) Figure 1 - Programming Language The year 1946 when the first computer ENIAC (Electronic Numerical Integrator and Computer) was also a big turning point in the history of human development. Soon after, a series of programming languages were born. Up to now, when people are entering the era of computers, of the 4.0 era with technology being a great driving force to boost the economy. Programming languages. Concepts like blockchain bigdata or artificial intelligence were also born to serve that purpose. To meet those needs, programming languages must increasingly be easier to understand so that programmers can use them fluently, but also need to meet the complex requirements of the digital economy.

1.2 Procedural Programing

1 .2.1 What is procedural programming and why is it so important?

Procedural Programming (POP) is the first basic programming paradigm a new programmer will learn. Essentially, procedural programming is code that directly instructs a device how to complete a task in sequential order. Flowchart of the program's control flow organization. Procedural programming divides the program into functions if the program is too large. A function is simply a subroutine containing a series of steps to be performed. In a nutshell, Procedural Programming is writing a list of instructions for the computer to understand what it must do to complete the task required by the programmer. (Bhatia, 2021) Figure 5 - Example of Procedural Programming Figure 4 - Code Python

1.2.2 Characteristics of procedural programming language

Procedural or Procedure Oriented Programming (POP): As the name implies, Procedure Oriented Programming contains step by step procedure to execute. Here, the problems get decomposed into small parts and then to solve each part one or more functions are used. Thus in POP approach, the problem is viewed as a sequence of things to be done, such as, input taking, calculating and displaying. The primary focus stays on functions which will be used to accomplish each task. Main Characteristics of POP: Following are the found main characteristics of POP,

  1. Puts much importance on Things to be Done.
  2. Large problems are divided into smaller programs known as functions.
  3. Most of the functions share global data.
  4. Data move openly around the system from function to function.
  5. Functions transfer data from one form to another.
  6. Employs top-down approach in program designing.
  7. In the cases of large program, bringing change is difficult and time consuming.
  8. Appropriate and effective techniques are unavailable to secure data of a function from others. 1.2.3 Key features of procedural programming a) Predefined functions Predefined functions are methods that are already defined in the library of the program you are using. However, you can only use statements once you have declared the library. For example, in C language. When you want to print the text "Hello world" to the screen, you need to declare the library “include<stdio.h>”.(Anon.,2014) The sample code would look like this: b) Local Variable A local variable is a variable declared in the main structure of a method and limited to the local scope to which it is provided. A local variable can only be used within the method in which it is defined, and if it is used outside of the defined method, the code will stop working. (Bhatia, 2021) c) Global Variable Figure 6 - Hello Word in C language

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. First, we need to generalize the requirements of the scenario as follows:

  1. Enter student ID, student grades and store these in 2 separate arrays.
  2. Print all student IDs along with their grades.
  3. Know which student has the highest score and the lowest score.
  4. There needs to be an option menu of the above features and need to return to the menu when an option is made.
  5. There should be an option to exit the program. 2.1 Variables and data types 2.1.1 Variables Variables are used to store information that is referenced and manipulated in computer programs. It also provides a way to label data with descriptive names so that readers and ourselves can understand the)^ program more clearly. It is convenient to think of variables as containers that hold information. Its sole purpose is to store labels in data in memory. This data is available throughout the program. Source: (Launch school, 2021) Name Size (byte) Description Char 1 Store single character information Int 4 Stores numeric data Float 4 Stores values containing decimal places (precision of up to 6 digits) Double 8 Stores values containing decimal places (precision of up to 10 digits) Void This is used to indicate the compiler that there is nothing to expect 2.1.2 Data types The data type of a value (or variable in some context) is an attribute that indicates the type of data a value can have. In most cases, the term is used in programming languages such as C/C++, Java and C# in connection with static typing of variables, where variable types are notified at compile time. Data types include storage classifications such as integers, floating point values, strings, and characters etc.

A data type defines certain characteristics of data used in a software program and tells the compiler about predefined properties required for a particular variable or related data object. (Techopedia, 2021) Figure 9 - : Data types in C language (Mishra, 2021) Names Data Types Description IDs Int ID of student Grades Float The grades of student N Int The maximum students input in program Current Int The number of student current Choices Int Reporting options that users choose Max Float The highest grades of student Min Float The lowest grades of student  The following table shows data about these variables, which I will use this program, including their names, data types and its description.

  • In this program, to avoid user mistype with request, user will receive a notification error and the program request user to enter again. Figure 12 - Example of using "if-else" statement functio 2.2.3. “Switch case” statement function
  • At first, the program will evaluate the condition inside “switch” and compare it with the values of each “case” label. Then, if there is match, the statement following the matching label are executed until “break” occur. If no match is found, the default statement is executed. If break is not used, all statements are executed after the matching label.
  • In my report, I will use it to declare different options which users choose to report in “Menu”. It will have 4 options:
    1. Enter the student’s IDs and grades
    1. Print all information of current student
    1. Find the highest and lowest grades
    1. Exit the program
  • If I wanted to find the person with the highest or lowest grades, I would choose 3, after finishing, I can choose 1 to enter information of new student or choose 4 to exit the program

Figure 13 - Hierarchy diagram program

2.3. Loop statement

2.3.1. “For” statement function

  • The initialization statement is executed only once. Then the test expression is evaluated. The “for” loop ends when the test expression evaluates to false. However, if the test expression evaluates to true, a statement inside the “for” loop body is executed to update the update expression. The retest expression is evaluated.
  • This process continues until the test expression becomes false. If the test expression is false, the loop ends. Figure 15 - Example of using "for" statement function

2.3.2. “Do – while” statement function

  • The body of the “do-while” loop is executed once. Only in that case the test expression is evaluated.
  • If the test expression is true, the loop body is re-executed and the test expression is evaluated.
  • This process continues until the test expression becomes false.
  • If the test expression is false, the loop ends.

Figure 16 - Example of using "Do-while" statement function 2.4. Functions

  • A function is group of statements that work together. Every C program has at least one function that is main( ), and the most trivial program can define any additional functions.
  • You can split the code into different functions. It’s up to you know to split your code into multiple functions, but logically splitting each function is the same as performing a particular task.
  • The function declaration tells the compiler about a function’s name, return type, and parameters. A function definition provides the actual body of the function.
  • The C standard library provides a variety of built-in functions that your program can call. For
  • example, strcat( ) connects two strings, memcpy( ) copies the memory location to another location and uses more functions.
  • Functions may also be called methods, subroutines, procedures, and so on. (tutorialspoint, 2021)

3.2 Flowcharts As mentioned above to be able to understand more about the guessing algorithms behind the program's functions, we need to add flowcharts to be able to better understand that. To be able to explain in detail, I will have 6 flowcharts to explain the problems of: Enter student number, enter student's grade and name, menu control, student rankings, find max grade and find min grade. 3.2.1 Input number student To be able to enter the number of students, we need to have an indispensable condition that the number of students must be greater than zero. Because there cannot be a single student or the number of students is negative. Here is my diagram: Diagram 2 - Input Students As you can see when the program starts running, the program will ask the user to enter n (n is the number of students to manage). After the user has finished entering, the program will check the condition (n >=0). If this condition is true, the program will string Name student and two array

grade student and id student. If the condition is false, the program will print to the screen "n is not available" and ask the user to re-enter until n true with the condition, then it will end.

3.2.2 Input and Print name and grade of students

After we have the number of students to manage, next we need the user to enter their scores in turn. Of course, there will also be a and condition with the name and score so that errors can be avoided when creating the table. In which the score of the student entered must be less than 0 and greater than 10. The character limit of the student’s name is from 4-23 characters and only includes alphanumeric characters and space characters.

3.2.3 Menu Control.

To create a control menu for the program, we must include the menu in the switch-case statement and nest it in the do-while loop. In addition to being able to exit the loop, we also need an option so that the option matches the condition of the "while:" statement in the do-while loop. And here is my schematic: Diagram 3 - Menu control