Procedural Programming in C: Student Management System, Assignments of Computer Science

prog102-asm2 effective for everyone

Typology: Assignments

2020/2021

Uploaded on 09/25/2021

nc42131
nc42131 🇻🇳

4.8

(47)

8 documents

1 / 31

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Nguyen Xuan Cong-GCH200253
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
PROG102: Procedural Programming
Submission date
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Student Name
Student ID
Class
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
Grading grid
P4
P5
M3
M4
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download Procedural Programming in C: Student Management System and more Assignments Computer Science in PDF only on Docsity!

ASSIGNMENT 2 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PROG102: Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Student ID Class 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 Grading grid P 4 P 5 M3 M4 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

  • I. INTRODUCTION Contents
  • II. IMPLEMENTETION
    • II.1. HEADER
    • II.2. PRINT LINE FUNCTION
    • II.3. ID MAX FUNCTION
    • II.4. INPUT STUDENT INFORMATIONS FUNCTION
    • II.5. UPDATE STUDENT INFORMATION FUNCTION
    • II.6. DELETE STUDENT INFORMATION FUNCTION
    • II.7. SEARCH STUDENT BY NAME FUNCTION................................................................
    • PERFORMENCE FUNCTION II.8.CALCULATE THE AVERAGE SCORE AND GRADE THE ACADEMIC
    • II.9. SORT STUDENT BY AVERAGE FUNCTION
    • II.10. DISPLAY STUDENT HAVE MAX AVERAGE FUNCTION
    • II.11. DISPLAY STUDENT HAVE MIN AVERAGE FUNCTION
    • II.12. DISPLAY STUDENT FUNCTION
    • II.13. MAIN...............................................................................................................................
  • III. PROGRAM RESULTS.........................................................................................................
    • III.1. INPUT STUDENT AND DISPLAY STUDENT LIST
    • III.2. UPDATE STUDENT INFORMATION
    • III.3. DELETE STUDENT........................................................................................................
    • III.4. FIND STUDENT
    • III.5. SORT STUDENT BY AVERAGE
    • III.6. SHOW STUDENT HAVE MAX AVERAGE
    • III.7. SHOW STUDENT HAVE MIN AVERAGE
    • III.8. EXIT PROGRAM
  • IV. TESTING
    • IV.1. TEST CASE
    • IV.2. TEST ANALYSE
  • V. EVALUATION........................................................................................................................
    • V.1. CONDITION STATEMENTS
V.2.ITERATION STATEMENT .............................................................................................. 31
VI. CONCLUSION ...................................................................................................................... 31

I use void as a function return type, the function does not return any value. I use int as a function return type, the function does return value.

II.2. PRINT LINE FUNCTION

This function prints a line with n characters "". For presentation purposes. n: is the number of "" characters that will be printed to the screen. This function ends the operation and clears the previous screen, allowing the next operation to be performed. “ system(“cls”) ” to clear previous screen, “ getch ” to pause the menu until a key is pressed, “fflush(stdin)” to clear cache, avoid overflowing memory.

II.3. ID MAX FUNCTION

The requirement of the problem is that the student id automatically increases. So I will create this function to get the largest id of the list of students a[]. When add new student, the id will increase by 1 and idMax1 will be updated. a[]: is the student list array. n: amount of student in the list.

II.4. INPUT STUDENT INFORMATIONS FUNCTION

This function is used to add new students to the student list. I split into two functions:

  • void inputstudent(STD &stdx, int id, int n)
  • void inputstudentinformation(STD &stdx, int id) &sv: enter student information sv. Use & reference, meaning the information will be changed both inside and outside the function.

a[]: is a list of students. id: is the id (auto increment) of the student. n: is the number of students in the list. void inputstudentinformation(STD &stdx, int id) to input information of student who added. You enter student information then use the function Average and status to calculate average and identify status of that student inputed. void inputstudent(STD &stdx, int id, int n) to add new student. I used function printLine for presentation and increase n by 1. Do the function inputstudentinformation.

II.5. UPDATE STUDENT INFORMATION FUNCTION

This function is used to update student information by ID. With this function we will split into the following two functions:

  • void updatestudentinformation(STD&stdx)
  • void updatestudent(STD a[], int id, int n) &sv: enter student information sv. Use & reference, meaning the information will be changed both inside and outside the function. a[]: is a list of students. id: is the id (auto increment) of the student. n: is the number of students in the list

II.7. SEARCH STUDENT BY NAME FUNCTION

This function is used to search for students in a list by name. Does not distinguish uppercase and lowercase letters. a[i]: list of students name[]: the keyword to compare with student’s name in the list n: number if students in the list

II.8.CALCULATE THE AVERAGE SCORE AND GRADE THE ACADEMIC

PERFORMENCE FUNCTION

Average function is used to calculate average of 3 subjects of each students in the list Status function is used to identify if student passed or failed. If average >=6, student is passed. If not, student failed. I used “strcpy” to copy string of status point to student’s status.

II.9. SORT STUDENT BY AVERAGE FUNCTION

This function used to sort student list according to the average score in ascending order a[i]: list of students n: number if students in the list

  1. Assign i=
  2. Assign j=i+
  3. If j<n:
    • If a[i]>a[j], swap a[i] and a[j].
    • j=j+
    • return to step 3
  4. If i<n
    • If true i=i+1 and return to step 2
    • If false, end the function and break back to main menu.

II.1 0. DISPLAY STUDENT HAVE MAX AVERAGE FUNCTION

n: number of student in the array i, j: position of student in the array First, I assign i=0 and max =a[0] (the first value in array).

that smallest element with the element it is traversing ( find the smallest element in the range from a[j] to a[n-1]). If a[j+1] is smaller than min, then a[j] is the smallest. Min=a[j+1].Average (Save the newly found min position). If n=1 (have 1 student in the array), student average is min. Position of student is 0. If n not equal 1 or n more than 2, display: “There are no student in the list”. When i is different from - 1 or there are value i in array, display the name and average of that student to the screen.

II.1 2. DISPLAY STUDENT FUNCTION

Function printLine(130) for the presentation, use “For” to display student and their infomation in the list to the screen

II.1 3. MAIN

This is the function where other functions will take order as well as every other command is created and adjusted. In main, I declare the data types of the variables first:

  • op: is the value you enter to select an option in the menu.
  • arraySTD[]: store an array of student structs.
  • amountSTD: the current number of students of the arraySTD array.
  • idCount: is the auto-incrementing id counter of the student. Note: functionName(a,n) mean do the function for array a with n variable This menu will show up at the first time you run the program and after you finish one case.

Getting to the menu operation, I used “while” to take orders repeatedly. Here how it’s going:

  • Display the menu operation, showing options and orders
  • Read the number from the keyboard to determine which option the user requests and we get into the “switch…case” conditional statements: ▪ Case 1 : Add student to the student list Display: “Add student”, “idCount++” and “amountSTD++” mean increase number of students in the list by 1when add new student. Do the function inputstudent it enter student information then display ”Add student successful”. Do function pressAnyKey to end the function and break back to main menu. ▪ Case 2 : Update student information in the student list by enter the student ID If student in the list is higher than 0, display: “Input ID” and “Update student information”. Then use “scanf” to get id variable that you want to find student. Do the function updatestudent the enter information. If not, Display: “There are no student in the list”. After all, use function pressAnyKey to break function and return to main menu.

Case 6 and 7 : Show student have highest average and student have lowest average If the amount of student in the array is >0, display “Show student have highest or lowest average” and do the function showmax or showmin. If not, display: “There are no student in the list”. After all do the function pressAnyKey then break and go back to the main menu. ▪ Case 8 : Display student list: If amount of student array is >0, do the function showStudent. If not, display: ”There are no student in the list”. After all do the function pressAnyKey then break and go back to the main menu. ▪ Case 0 : Break from the iteration, end the program ▪ Another cases : users might make mistakes of typing the wrong number, this is when a notification of retyping

  • If the number orders are different from 9 , then the loop is still going

III. PROGRAM RESULTS

III.1. INPUT STUDENT AND DISPLAY STUDENT LIST

I choose case 1 to enter each student to the list. Then choose case 8 to display all students to the screen. ID, name, gender, age, Math grade, Physic grade, Chemistry grade will be entered by hand. The average and status will be calculated by the program.

III.2. UPDATE STUDENT INFORMATION

I choose case 2 then enter the ID which student I want to update information. Then I choose case 8 to display the updated list to the screen. The student I updated is the student who have ID is 3.

III.5. SORT STUDENT BY AVERAGE

I choose case 5 to sort the student list by with the ascending average order. The list will be sorted and displayed to the screen.

III. 6. SHOW STUDENT HAVE MAX AVERAGE

I choose case 6 to find who have the highest score in the list.

III. 7. SHOW STUDENT HAVE MIN AVERAGE

I choose case 7 to find who have the lowest score in the list