ASSIGNMENT 2 Procedural Programming, Assignments for Computer Science, Study Guides, Projects, Research of Computer Science

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,

Typology: Study Guides, Projects, Research

2020/2021

Uploaded on 10/21/2021

nguyen-thai-hiep
nguyen-thai-hiep 🇻🇳

1 document

1 / 28

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 Prog102: Procedural Programming
Submission date 13/10/2021
Date Received 1st
submission
Re-submission Date Date Received 2nd
submission
Student Name Nguyen Thai Hiep Student ID GCH200524
Class GCH1001 Assessor name
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 Hiep
Grading grid
P1 P2 P3 M1 M2 D1
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download ASSIGNMENT 2 Procedural Programming, Assignments for Computer Science and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog102: Procedural Programming Submission date 13/10/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Nguyen Thai Hiep Student ID GCH Class GCH1001 Assessor name 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 Hiep Grading grid P1 P2 P3 M1 M2 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

output. Simply put, procedural programming involves writing down a list of instructions to tell the computer what it should do to finish the task. Procedural Programming

  1. Some typical programming languages

MAIN

Procedure A Procedure B Procedure C Procedure Y Procedure X

C++: C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language

PYTHON: Python is an interpreted high-level general-purpose programming language. Almost, programs language have file extension corresponding such as Python is .py, Ruby is .rb…..

  1. Every language has strengths and weaknesses Most programming languages have the same strengths and weaknesses. For example: ❖ C++: Powerful objects and it is the language that you learn first in university. But it is quite complex and difficult to learn. ❖ Pascal: Is the good program to learn, but it is not as flexible as C++
  2. The features of procedural programming
  • Local Variable: A local variable is a variable that is declared in the main structure of a method and is limited to the local scope it is given.
  • Global Variable: A global variable is a variable that is declared outside every other function defined in the code.
  • Parameter Passing: Parameter Passing is a mechanism used to pass parameters to functions, subroutines, or procedures.
  • Predefined functions: A predefined function is typically an instruction identified by a name. One example of a pre-defined function is ‘charAt()’, which searches for a character position in a string.
  • Modularity: Modularity is when two dissimilar systems have two different tasks at hand but are grouped together to conclude a larger task first.
    1. The characteristics of procedural programming
  • Procedural programming follows a top-down approach.
  • The program is divided into blocks of codes called functions, where each function performs a specific task.
  • Procedural programs model real-world processes as 'procedures' operating on 'data'.
  • The data and functions are detached from each other.
  • The data moves freely in a program.
  • It is easy to follow the logic of a program.
  • A function can access other function's data by calling that function.
  • So, it can be said that procedural programming involves using to evaluate and analyze all differentiating areas and provide better solutions to complex programs. II. IDENTIFY THE PROGRAM UNITS AND DATA AND FILE STRUCTURES 1. Library Before create a program, the first thing you always need to do is Declare library. There are some library commonly used: <stdio.h> will have some basic command such as : printf, scanf,…..

INPUT

#include <stdio.h> void main () { int age = 19; printf("Age : %d",age); } OUTPUT Age : 19 Normally, in command ‘printf’, Int will be ‘% d ’ or ‘% i ’, Float will be ‘% f ’, ‘%. 1f ’ or ‘% 1. f ’, [%f will show full decimal, %.1f will show one decimal and %1.f will rounding number], Char will be ‘% c ’, Char is an acronym for a character. Depending on the case, char will be taken in ASCII. For String , it will be ‘%s’. In C++, will not have variable ‘string’. [30] is character limit in this variable

  1. Get info from keyboard For Int, Float Use ‘scanf’ to get characters from keyboard. For Char, String Use ‘gets’ or scanf(“%[^/n]s) to String, use getchar to Char. [30] make this list for variable name, each containing up to [30] characters
  2. Structures Some selection structures we used in program: Switch-case
  • Is a control and branching construct that can be completely replaced by an if else. Using switch case in this project will make it easier to read and understand.
  • Note: if there is no break in the case statement, the program will execute the statements in the next cases until it meets the break statement. Fflush(stdin) To clear the program's temporary memory for the above garbage values to do not occur. While-loop For the first request, we should choose a do-while loop. Do-while will check for conditions that do not satisfy the problem. If it’s not satisfy the problem, it will check again until user enter correct request. For-loop

selection items from menu max Float Scan highest grade min Float Scan lowest grade check Boolen To check. If user didn’t input information first. Another option could not use.

  1. Review WBS Manage grade of students Exit program Find the student have lowest score Find the student have highest score Show information of students Input total students Input information students

WBS - WBS to breakdown a problem into small ones. After I read the scenario, I understood the problem and had solutions to manage grades for students by using WBS. In my WBS, I have subdivided it into 5 functions of problem to solve problem. When teacher start program, teacher will see a menu that have 5 options: ❖ Option 1: After teacher enter total of student, next, teacher must enter information of their student, (Name, ID, Grade), if not, they can’t use another option. ❖ Option 2: Show information, this function will print all of information that import in option 1 to screen. ❖ Option 3: Find and print the student who have highest score to screen with their same ID. ❖ Option 4: Function same as option 3. But instead of looking for the highest scorer, we find the lowest scorer. ❖ Option 5: To exit program when teacher need to exit program. 1) Use-case diagram for student’s manage system 14 Input Name Input ID Input Grade Name/ID include Enter information of student Input total of student include Grade Show information

Explain main program by pseudo code: Step 1: START Step 2: DECLARE the variable n, ID[], grade[], name[], check, option

Step 3: SET check=false Step 4: CALL printMenu() Step 5: Input option Step 6: If option=1 then Step 6.1: CALL inputList() Step 6.2: SET check=true Step 7: ELSE (check=false) is true, return Step 5. Step 8: IF option=2 then CALL printList() Step 9: IF option=3 then CALL findMax() Step 10: IF option=4 then CALL findMin() Step 11: IF option=5 then GO TO Step 13 Step 12: WHILE option != 5, repeat Step 5 Step13: STOP Menu list

Explain menuList by pseudo code: Step 1: START Step 2: PRINT (“Input total student(3-30) ”) Step 3: PRINT ("1. Input information") Step 4: PRINT ("2. Show information") Step 4: PRINT ("2. Show information") Step 5: PRINT ("3. Find the student have highest score.") Step 6: PRINT ("4. Find the student have lowest score.") Step 7: PRINT ("5. Exit") Step 8: PRINT (“ Input your choice “) Step 9: STOP Input list