Your next task is to implement the software that you designed in previous steps. You need Programming Languages Can-Tho University 22 pag. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PROG102: Procedural Programming Submission date November 13 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Huynh Chi Bao Student ID GCC200363 Class GCC0904 Assessor name Le Huynh Quoc Bao 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 Huynh Chi Bao Grading grid P4 P5 M3 M4 D2 1|Page Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Summative Feedback: Grade: Resubmission Feedback: Assessor Signature: Date: Lecturer Signature: Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 2|Page Table of Contents Screenshots & Explain........................................................................................................................................ 5 I. 1. Problem ............................................................................................................................................................ 5 2. Problem solving ............................................................................................................................................... 5 II. 1. Coding standard.............................................................................................................................................. 5 2. Library in the program .................................................................................................................................. 6 3. Variables in the program ............................................................................................................................... 6 4. Do – while loop to enter the number of students.......................................................................................... 6 5. Function input information of student’s: ..................................................................................................... 7 6. Function output information of student ....................................................................................................... 8 7. Function find highest and lowest grades of student. .................................................................................... 8 8. Menu options. ................................................................................................................................................ 10 III. Testing (P4).................................................................................................................................................... 12 1. Screenshot ...................................................................................................................................................... 12 2. Test plan (P5) ................................................................................................................................................ 15 IV. V. Implements (P4, M3) ...................................................................................................................................... 5 Analyze (M4) ................................................................................................................................................. 19 Evaluation (D2) ................................................................................................................................................. 22 Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 3|Page Figure 1.Local variable using camels -cased letters ...................................................................................................... 5 Figure 2.Constant name using uppercase letters ......................................................................................................... 5 Figure 3.Library of the program .................................................................................................................................... 6 Figure 4.Global variables of program. .......................................................................................................................... 6 Figure 6.Loop to enter number students...................................................................................................................... 6 Figure 5.Input information of student. ......................................................................................................................... 7 Figure 7.Print information of student to the screen. ................................................................................................... 8 Figure 8.View student has highest grade...................................................................................................................... 8 Figure 9. View student lowest grade. ........................................................................................................................... 9 Figure 10. Menu options of program (1) .................................................................................................................... 10 Figure 11. Menu options of the program (2) .............................................................................................................. 11 Figure 12.Menu option. .............................................................................................................................................. 12 Figure 13.Input ID and Grade of student .................................................................................................................... 12 Figure 14.Output information of students. ................................................................................................................ 13 Figure 15.Find highest grade of students. .................................................................................................................. 13 Figure 16.Find lowest grade of students. ................................................................................................................... 14 Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 4|Page I. Screenshots & Explain 1. Problem 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 this 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. 2. Problem solving I write a program to used manage student information. The main function of program is: II. - Input student information. (Student ID, student grade) - Output student information. (Print to the screen) - Find the student has highest grade. - Find the student has lowest grade. - Exit. Implements (P4, M3) 1. Coding standard - Local variables must be named using camel – cased letters that star with lowercase letters (e. g. grade). Figure 1.Local variable using camels -cased letters - Constant names must be formed using only uppercase letters (e.g. ID). Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 2.Constant name using uppercase letters - The name of the function clearly and concisely explains why using the function. 5|Page - Indentation: + A space is required after entering a comma between the arguments of both functions. + Each nested block should be properly indented and spaced. + Proper indentation should be at the beginning and end of each block in the program. 2. Library in the program In this program, I use <stdio.h> library because it provides the core of the input function. This library contains the print function to display the input data to the screen. Figure 3.Library of the program 3. Variables in the program - I use local variables to declare variables used in the program: + Integer: ID (ID of students) + n (Number of students), i, j. + Float: grade (Grade of students) Figure 4.Global variables of program. 4. Do – while loop to enter the number of students Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 5.Loop to enter number students 6|Page - The main objective of this loop is the number of input students - If the student enters incorrectly, the program will send a message on the screen asking the teacher to re-enter the student number ("Incorrect! Please re-enter:"). 5. Function input information of student’s: - Help you check if you have entered the recently entered ID, use the for loop to check in the array ID. - Input student’s ID and check for duplicates. If it is duplicated, the user will have to reenter it. - Input student’s grade and check if grade is valid or not. If it not, the user need to input again. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 6.Input information of student. 7|Page 6. Function output information of student Help you print student information to the screen. Figure 7.Print information of student to the screen. 7. Function find highest and lowest grades of student. Help you find the student has highest grade and print to screen. - Max = Grade [0], max ID =IDs [0]. - i from 0 to (n-1) (n is the number of student). - If max < grade[i] then max = grade[i], max ID= IDs[i] - Print the result on the screen. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 8.View student has highest grade. 8|Page Help you find the student has lowest grade and print to screen. - Min = Grade [0], min ID =IDs [0]. - i from 0 to (n-1) ( n is the number of students) - If grade[i] < min then min = grade[i], min ID= IDs[i] - Print the result on the screen. Figure 9. View student lowest grade. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 9|Page 8. Menu options. Help to output more options in the menu. - Input student ID and grade. - View student ID and grade. - Find the highest of student. - Find the lowest of student. - Exit program. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 10. Menu options of program (1) 10 | P a g e Figure 11. Menu options of the program (2) Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 11 | P a g e III. Testing (P4) 1. Screenshot Menu option: Figure 12.Menu option. Input student information: Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 13.Input ID and Grade of student 12 | P a g e Output information of students to the screen: Figure 14.Output information of students. Find the highest grade of students: Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) Figure 15.Find highest grade of students. 13 | P a g e Find the lowest grade of students: Figure 16.Find lowest grade of students. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 14 | P a g e 2. Test plan (P5) No. - Creator: Huynh Chi Bao - Create date: November 13, 2021 Test case Function Input Data Expected Actual output Result output 1. Verify that Input - Enter number Student Student student ID information and grade will of students: 3 1 - Student user enters valid informatio Pass information - Student ID 1: n save into save into array: save into array if Student grade: 7 array: ID[]={1,2,3} ID[]={1,2, Grade[]={7,8. 3} 5,9} - Student ID 2: Grade[]={ information 2 7,8.5,9} - Student grade: 8.5 - Student ID 3: 3 - Student grade: 9 2. Verify that Enter Display Display duplicate. error message “ID is IDs” are message duplicate” displayed if “ID the user duplicate” “Duplicate - error Pass is enters a duplicate ID number. 3. Verify that “Number of student Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) - Enter number Display of students: -5 error message Display error Pass message “Number of 15 | P a g e must “Number be student positive of student be number” is must displayed if positive user enters number” number must positive be number” of student with negative number. 4. Verify that - Enter number Display “Student’s grade from of students: 3 is 0 Display error message “Student’s - Student ID 1: message to 1 10. Please, - Student enter again” grade: 15 “Student’s grade grade is from 0 is to 10. Please, from 0 to enter again” is displayed 10. Please, if enter user error Pass again” enters invalid student’s grade . 5. Verify that Display ID[]={1,2,3} List of List of student Pass “Student student ID Grade[]={7,8.5, student ID ID and grade: information and grade and grade: will - Student displayed when 9} user choose ID 1: 1 - Student Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) grade: 7 menu “Print - Student Student ID ID 2: 2 - Student ID 1: 1 - Student grade: 7 - Student ID 2: 2 and grade”. 16 | P a g e - Student - Student grade: 8.5 grade: 8.5 - Student - Student ID 3: 3 ID 3: 3 - Student - Student grade: 9 grade: 9 6. Verify that Find ID[]={1,2,3} Student Student Grade[]={7,8.5, has highest grade: 9} highest - “IDs” will be grade: grade:10 displayed - - “Lowest student’s grade” and min grade when the Highest has Pass Highest ID grade: user 10 chooses the - ID:3 menu “Find who has student lowest grade. 7. Verify that Find ID[]={1,2,3} Student Grade[]={7,8.5, has lowest lowest grade: 9} grade: - - Lowest grade:7 displayed grade: - when 7 “Highest student’s grade” and max grade “IDs” will be the user - Student has Pass Lowest ID:1 ID:1 chooses the menu “Find who Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) has student 17 | P a g e highest grade Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 18 | P a g e IV. Analyze (M4) No. 1. Test case Function Verify that Input student Student ID and grade Result Pass Evaluation The program has performed information will effectively and save into array saved the data if user enter in the array valid information 2. 3. Verify that Pass The program “Duplicate IDs” has performed are displayed if effectively and the user enters require user a duplicate ID value valid number. again Verify that “Number student be Pass The of has performed must effectively and positive require user valid number” is value displayed if again user program enters number of student with Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) negative number 19 | P a g e 4. Verify that Pass The program “Student’s has performed grade is from 0 effectively and to 10. Please, require user enter again” is value valid displayed again user if enters invalid student’s grade . 5 Verify that Display student Pass “Student ID and grade The program has performed information will effectively and displayed when printed user Student ID and choose menu “Print Grade from Student ID and the array were grade”. saved to display 6 that Find Verify student’s Pass The program “Lowest grade” min grade has performed and “IDs” will effectively and be found displayed when the user chooses lowest grade the menu “Find who has the Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) student lowest grade. 20 | P a g e 7 that Find Verify student’s Pass The program “Highest grade” max grade has performed and “IDs” will effectively and be found displayed when the user chooses the highest grade the menu “Find who has student highest grade Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 21 | P a g e V. Evaluation (D2) After testing and checking this program, I realized that: - Advantages: It can store student’s ID and grade. It can check whether the entered ID is the same or the entered grade is valid. If the ID duplicates or the grade is invalid, the teacher will be prompted to re-enter. - If all the data entered by the teacher is valid, the program will print the student information on the screen to find the student with the lowest and highest grade. - The program has the option to exit and exit the program when the teacher completes the program’s session. - Disadvantages: If the teacher enters the wrong data type required for the command, the program will receive an error. In the test log table above, when the teacher enters a letter as a student’s ID, the program fails and an infinity loop occurs even if the command requires a number. - It is more difficult for teachers to know who a student is by simply entering the student ID. - If the teacher enters the wrong student’s data and wants to re-enter it, the only way is to reenter the data from the beginning and there is no re-entry option for a particular student. - In some cases, when the teacher enters the invalid data type required by the command, but the program continues to run and displays the data on the screen, error data is displayed. Conclusion: Although the program has many errors, it can still be seen as a complete student management program that basically meets the needs of teachers. In the future, I will try to improve my ability to fix existing bugs, optimize and complete this program. Document shared on www.docsity.com Downloaded by: thanhson (duongvanthanhson5@gmail.com) 22 | P a g e