Analysis and Design of a Procedural Programming Solution for a Grade Management System, Assignments of C programming

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.

Typology: Assignments

2021/2022

Uploaded on 03/07/2022

Hermes0066
Hermes0066 🇻🇳

5

(3)

2 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Date: 9/2/2022
Tran The Hao
Class: GCS1003B | ID: GCS210785
PROCEDURAL PROGRAMING
REPORT
ASIGNMENT 1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Analysis and Design of a Procedural Programming Solution for a Grade Management System and more Assignments C programming in PDF only on Docsity!

Date: 9/2/

Tran The Hao

Class: GCS1003B | ID: GCS

PROCEDURAL PROGRAMING

REPORT

ASIGNMENT 1

ASSIGNMENT 1 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date 22 /02/2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name TRAN THE HAO Student ID GCS Class GCS1003B Assessor name LE NGOC THANH 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 P1 P2 P3 M1 M2 D

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 Assignment Title 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 characteristics and features of P2 Identify the program units^ procedural programming. 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.
  • Assignment Brief 1 (RQF)
    • Higher National Certificate/Diploma in Computing
  • A. Introduction:
    • I. Programing language:
        1. Definition:
        1. Machine Language:............................................................................................
        1. Assembly Language:
        1. High-level Language:
    • II. Procedural Programing (P1):
        1. Definition:
        1. Advantage:
        1. Disadvantage:
    • III. CHARACTERISTICS OF PROCEDURAL PROGRAMMING (M1):
        1. Predefined functions:
        1. Local variables:
        1. Global variables:
        1. Modularity:........................................................................................................
        1. Parameter Passing:
  • B. ANALYZE THE SITUATION:
    • I. Variables and Data Types (P2):
        1. Variables:
        1. Data types:
    • II. Conditional Statement (P2):
        1. If:
        1. Switch-case:
    • III. Loop Statement (P2):
        1. For:...................................................................................................................
        1. Do-while:
        1. While:
    • IV. Function of program (P2):....................................................................................
        1. Split Function:
        1. Hierarchy Diagram:
    • V. Diagram (P3):
        1. Use-case diagram:
        1. Flowchart:.........................................................................................................
    • VI. EVALUATE THE PROGRAM (M2, D1):
  • C. Reference:

A. Introduction: I. Programing language:

1. Definition:

A programming language is a set of symbols, grammar, and rules with which people can translate algorithms into programs that will be executed by a computer. Programmers use programming languages to communicate with machines. Most programs have a set of highly structured rules. The main categories of programming languages are low-level language (Machine languages, Assembly language) and high-level language.

2. Machine Language:............................................................................................

Machine language is a collection of binary digits, orbits, that the computer reads and interprets. Machine language is the only language a computer can understand directly. Machine language is a language that supports machine-side programming or does not provide human-side programming. It consists of (binary) zeros and ones. Each statement in a program is represented by a numeric code, and numeric addresses are used throughout the program to refer to locations in computer memory. Microcode allows some of the more powerful machine-level instructions to be expressed in the form of a set of basic machine instructions.

4. High-level Language:

A high-level language is a language that supports the human and application side of programming. A language is a machine-independent way of specifying the sequence of operations required to accomplish a task. High-level language lines can perform powerful operations and correspond to dozens or hundreds of instructions at the machine level. As a result, more programming is now done in high-level languages. Examples of high-level languages are C++, Java, Python, etc. II. Procedural Programing (P1):

1. Definition:

Procedural programming is a programming paradigm that is built around the idea that programs are sequences of instructions to be executed. They focus on breaking down programs into named sets of instructions called procedures, which are analogous to functions. A procedure can store local data that is not accessible from outside the procedure's scope and can also access and modify global data variables. This makes the procedure more versatile and efficient. In this case, the functions take precedence over the data. The program in the programming procedural language consists of a series of instructions, each of which requires the computer to perform a certain task, such as reading the user input, performing the necessary calculations, and presenting the results. When the size of the program increases, it is divided into smaller components called procedures or functions. Several functions need to be written to accomplish this task.

Since the same function is generated from many locations, these functions prevent duplication of the code. Only medium size programs are acceptable for this method. There are two types of data in procedural programming: local and global. Local data are data that are contained within a function, and global data are data that are not included in any function. The only function in which local data are identified has access to them. As a result, each function has access to both local and global data. Other functions cannot access local data from one function. If two or more functions require access to the same data, they should be global. On the other hand, global data can be inadvertently changed by another programmer. The division of data and functions is not a good model for real situations. As a result, procedural programming cannot properly reproduce the real system. Some programming languages in which procedural programming can be implemented include COBOL, FORTRAN, C, and Pascal.

2. Advantage:

  • Procedural programming is excellent for general-purpose programming.
  • Coded simplicity combined with ease of implementation for compilers and interpreters. •The program flow can be tracked easily.
  • Large size A variety of Books and online course materials about tested algorithms, facilitating learning along the way.

III. CHARACTERISTICS OF PROCEDURAL PROGRAMMING (M1):

1. Predefined functions:

A predefined function is usually a statement identified by name. Typically, predefined functions are built into higher-level programming languages, but they are derived from a library or registry, not from a program. One example of a predefined function is "charAt()" which looks up the position of a character in a string.

2. Local variables:

Local variables are variables that are declared in the method's main structure and are restricted to the specified local scope. A local variable can only be used in the method in which it is defined, and if used outside the defined method, the code will not work.

3. Global variables:

Global variables are variables declared outside of every other function defined in the code. Therefore, unlike local variables, global variables can be used in all functions.

4. Modularity:........................................................................................................

Modularity is when two different systems have two different tasks at hand but combine to complete a larger task first. Then, the tasks of each group of systems will finish one by one until all the tasks are completed.

5. Parameter Passing:

Parameter passing is a mechanism for passing parameters to functions, subroutines, or procedures. Parameter passing can be done by pass-to-value, pass-to-reference, pass-to-result, pass-to-value-results, and pass-to-name.

B. ANALYZE THE SITUATION: I. Variables and Data Types (P2):

1. Variables:

A variable is the name of the memory area where the program can change data. This location is used to store the value of the variable. The value of variable C can be changed in the program. Here, the type must be a valid C data type that contains char, w_char, int, float, double, bool, or any other user-defined object.; The list of variables may consist of one or more identifier names separated by commas. Some valid statements are shown here. The line int i, j, k; declares and defines the variables i, j, and k; which instructs the compiler to create variables called i, j, and k of type int. Variables can be initialized (setting an initial value) in their declaration. The initializer consists of an equals sign followed by a constant expression as follows:

2. Data types:

A data type in C programming is a set of values and deterministic actions on those values. C provides various types of data types that allow the programmer to choose the appropriate type for a variable to set its value. A data type in a programming language is a collection of data with fixed meanings and characteristics. Some of them are integers, floats, characters, etc. Often, programming languages specify range values for a given data type. The program uses a total of seven main variables. Includes three floating-point variables and three integer variables. The following table contains information about these variables, such as their names and data types.

II. Conditional Statement (P2):

1. If:

This is the most important tool in the selection process. Used to execute a single or group statement when the condition is true. If the condition is false, the statement is skipped and the program executes the first statement after the if selection structure to continue. The program uses the if statement structure to find the student with the highest grade function and the student with the lowest grade function. First, use a for loop to accept the Sgrade input from the array. The program begins comparing the inputs of the array one by one. If the value is high, Maxgrade will be assigned and the program will continue to run (Sgrade +1) times. The final value of Maxgrade is the highest grade. First, use a for loop to accept Sgrade input from the array. The program begins comparing the inputs of the array one by one. If the value is small, Mingrade will be assigned and the program will continue to run (Sgrade +1) times. The final value of Mingrade is the lowest grade.

2. Switch-case:

In C, the switch statement compares the value of a variable to some scenarios. When a case match is found, a block of statements related to that particular case is executed. Each case in the switch block has a unique name or number called an identifier. The user's value is compared to all cases in the switch block until a match is found. The value of the variable or expression in parentheses is compared to the value provided by the switch statement on each instance. If a match is found, the statement following the case is executed. If no match is found, the default statement is used. You must place a keyword break at the end of each case to exit the switch immediately after the statement is executed. In this scenario, the programmer defines an integer variable named n. There, the n is considered only once and compared to the value of the case. If a block of statements follows a case that has a matching value, the statements within that block will be executed. case 1 Input ID and grade of student

  • Step 4: Update the iterator value => Go back to Step 2
  • Step 5: End the loop. The situation is currently being reassessed. If it’s true, the loop will run and the procedure will repeat (body of the loop, then increment step, and then again condition). The ‘for’ loop ends when the condition becomes false. We use a for loop in the scenario to accept Sgrade inputs from the array. In the body of the loop, it will include the if statement. the for loop will continue to run Sgrade +1) times to find the highest and lowest grade. Then we will use a for loop to find out who the students with the highest or lowest grade are. By putting the if statement inside this loop. If grade = Maxgrade or grade = Mingrade then print the student's ID. So we have found the people with the highest grade and those with the lowest grade.

2. Do-while:

Unlike for and while loops, which verify the loop condition at the top, the do-while loop in C programming checks it at the bottom. A do-while loop is similar to a while loop, except it guarantees that it will be executed at least once. Two statement actions are available in the program: one for input variables and the other for scanning variable values. When the do-while command is executed, it begins processing the Sgrade values at the end. The loop condition is then used; if true, the loop will return to the start and the loop's body will be run once more. This procedure repeats itself until the condition no longer exists. The do-while loop is responsible for verifying the state of variables as they are typed in.

3. While:

In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. The syntax of a while loop in C programming language is Here, the statement can be a single statement or a block of statements. Condition is any expression and true is a non-zero value. The loop will keep repeating as long as the condition is true. If the condition is false, program control is passed to the line immediately following the loop.