Dựa trên các chỉ định và yêu cầu trong assignment, nếu bạn tuân thủ chúng một cách nghiêm ngặt và thực hiện công việc một cách cẩn thận, thì khả năng thành công của bạn là tuyệt đối, đạt tỷ lệ 100%. Bằng cách đáp ứng đầy đủ mọi yêu cầu và làm việc chăm chỉ, bạn sẽ đạt được kết quả mà bạn mong muốn.
Trang 1
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
Trang 2Student Name VU THANH TRUONG Student ID GCH211415
Trang 3
Summative Feedback: Resubmission Feedback:
Grade:
Assessor Signature:
Date:
Lecturer Signature:
Table of Contents
I Implementation: 5
1 Explain structure of program: 5
2 Program function: 9
3 How the functions are used in the program: 11
4 Important algorithms in your program: 14
II Program results: 15
1 Menu: 15
2 Input information: 15
Trang 4
3 Display information: 16
4 Display Highest Score: 17
5 Display Lowest Score: 18
6 Exit: 18
III Testing: 19
IV Evaluation: 20
1 Advantages of the program: 20
2 Disadvantages and difficulties of the program: 20
3 Future progress improvements: 21
V Conclusion: 21
Trang 5
I Implementation:
1 Explain structure of program:
• Display menu
This program is a student score management program The program includes a menu that allows the user to perform tasks such
as entering student information, printing out the information of all students, finding the student with the highest score, finding the student with the lowest score and exit the program
In the main() function, the program uses a do-while loop to execute the menu and asks the user to choose an option from 1 to 5 The program then uses a switch-case to perform the same action to the user's choice
Functions used in the program include:
• Input information:
- The inputStudentInfo() function is used to enter the information of the students, including IDs and grades This function takes as input the ID array, the score array, the number of students, the maximum score limit and the lowest score limit If a student's score is not within the specified limit, the program will ask the user to re-enter
+ The inputStudentInfo function takes four arguments: the student ID array (id), the student score array (score), the number of students (n), the highest score achieved by the student (m), and the lowest score obtained by the student gain can get (k) It uses
a for loop to cycle through all the students and ask the user to enter their ID and score It also checks if the point entered by the user is in the range m and k and prompts the user to re-enter the point if it is not in the range
+ first, the for loop will iterate n times, n is declared previously and represents the number of students to enter
Trang 6
+ After the student's score is entered and stored in the score array, the program breaks the line and moves on to the next student
in the for loop
• Show all student information
- The printAllStudentInfo() function is used to print the information of all entered students This function takes as input the ID array, the score array and the number of students
+ The printAllStudentInfo function takes three arguments: an array of student IDs (id), an array of student scores (score), and the number of students (n) It uses a for loop to cycle through all the students and print out their IDs and scores
+ First, the cout command is used to display a message about student information that is about to be displayed
Trang 7
+ Then the for loop is used to iterate n times, where n represents the number of students entered and stored in the id and score
arrays
+ In each iteration, the program will display the student ID and the student's score using the cout command The value of the
student ID will be taken from the id array at position i, and the student score value will be taken from the score array at position
i
+ After displaying information about that student, the endl command is used to convert the line and the program will continue to
repeat for the next student in the for loop
Trang 8- findStudentWithMinScore: This function is used to find the student with the lowest score Similar to the
findStudentWithMaxScore function, we use a loop to iterate through the list of students and find the lowest score In this function, we use two variables: minscore and peoplemin The minscore variable stores the value of the lowest score found in the list, and the peoplemin variable stores the ID of the student with the lowest score After finding the lowest score, we go through the list of students again to find the students whose scores are equal to minscore and display the information of these students
+ int minscore=score[3];: This is the declaration of the variable "minscore" with an initial value equal to the score value of the 3rd student
in the list This is the initial initial value to compare with the scores of other students
+ int peoplemin=id[1];: This is the declaration of the variable "peoplemin" with an initial value equal to the ID value of the first student
in the list This is the initial value to compare with the IDs of other students
Trang 9
- function findStudentWithMinScore(): This function is used to find the student with the lowest score It will find the lowest score in the score array and store the ID of the student with that score It then iterates over all the students in the score array and prints out the information of the students with the lowest scores
- In the main() function, the program uses a do while loop to repeat the menu display and run the functions
corresponding to the user's selection If the user chooses to exit, the program will end
2 Program function:
Trang 10
* Declare the library:
#include <iostream> : This is the first statement in the code, used to declare thev
iostream library in C++ This library contains the necessary definitions to use
input/output commands from the keyboard and display the console
using namespace std; : This statement allows to use the elements (functions,
variables, ) of the namespace "std" without having to type "std::" before each
element
* Variable:
Variables declared in the code:
MAX_STUDENT: constant, maximum value for the number of students declared array
'choice`: integer variable that stores the user's choice to perform functions capabilities in the
program
' id : array of integer type, storing student IDs
'score` : array of real numbers, storing student scores
'n` : integer variable that stores the number of students entered
`m : integer variable, which stores the highest possible score value for the student
`k : integer variable, which stores the lowest possible score the student can achieve
`` : integer variable, used to repeat actions for each element of net
'maxscore` : variable of type real number, stores the value of the student's highest score
`peoplemax : integer variable, which stores the ID of the student with the highest score
'minscore` : variable of type real number, stores the value of the student's lowest score peoplemin: an integer variable that stores the ID of the student with the lowest score
This program has the following functions:
Trang 11
- findStudentWithMinScore(int id[],float score[],int n): Finds the student with the lowest score in the list of students and prints that student's information, including the student's ID and the student's score If there are multiple students with the same lowest score, all of those students will be printed
In the main function, the program asks the user to choose one of the above functions to perform
Trang 14
4 Important algorithms in your program:
This program does not have complicated algorithms, but only performs basic tasks for managing student information
Functions in the program include:
- function inputStudentInfo: Takes as input an array of student codes and an array of scores, and the number of students
The function requires the user to enter the code and score of each student It checks if the score is between the lowest
and highest score entered initially, otherwise displays an error message and asks the user to re-enter it The function
does not return a value
- function printAllStudentInfo: Takes as input an array of student codes and an array of grades, and the number of
students The function displays information about all students, including their numbers and grades The function does
not return a value
- function findStudentWithMaxScore: Takes as input an array of student codes and an array of grades, and the number
of students The function finds the student with the highest score and displays the information of all students with the
same highest score The function does not return a value
- function findStudentWithMinScore: Takes as input an array of student codes and an array of grades, and the number of
students The function finds the student with the lowest score and displays the information of all students with the
same lowest score The function does not return a value
Trang 15
These functions are used in the main program to perform student information management tasks The program uses a loop to display the menu and ask the user to select the action to perform Actions are performed by calling the functions corresponding
to each menu option
II Program results:
Trang 16
3 Display information:
instead let's press the number 1 first to enter the student's information, If 1 is selected, the program will ask the user to enter the number of students (n), the highest score achieved by the student (m) and the lowest score achieved by the student (k) The program will then ask the user to enter each student's information, including ID and score If the score is not between k and m, the program will ask the user to enter it again This student information will be stored in the id and score array
Trang 17
If after entering student information by selecting number 1, you will be able to print out all student information by selecting number 2 However, if you have not entered student information by selecting number 1 before , the program will not print out any student information and only notices that no students have been entered
4 Display Highest Score:
Trang 18
If you press number 3 after entering student information by selecting number 1 and entering the necessary information, the program will display the student with the highest score For example, if there are 5 students and their scores are 1, 1, 10, 3, 10 respectively, the program will display "Student with highest score: ID=333, score=10 and ID=555, score=10"
6 Exit:
Trang 19
TC1
Testing the menu
Displaying the menu options
Displaying the menu options Pass
TC2
Testing the option to input student info
Number of students: 2, Highest score:
10, Lowest score:
Prompt to enter student ID and scores
Prompt to enter student ID and
TC3
Testing input validation for scores outside the highest and lowest range
Number of students: 1, Highest score:
Error message to re-enter the
TC4
Testing input validation for non-numeric characters
Number of students: 1, Highest score:
10, Lowest score:
Error message to re-enter the score
Error message to re-enter the
TC5
Testing input validation for negative number
of students
Number of students: -2, Highest score:
Student IDs: 1, 2;
Scores: 8, 9 1, 2, 8, 9
Display of all student IDs and scores
Display of all student IDs and
TC7
Testing the option to find student with highest score
Student IDs: 1, 2;
Scores: 8, 9 1, 2, 8, 9
Display of student with highest score (ID: 2, score: 9)
Display of student with highest score (ID: 2, score: 9) Pass
Trang 20
TC8
Testing the option to find student with lowest score
Student IDs: 1, 2;
Scores: 8, 9 1, 2, 8, 9
Display of student with lowest score (ID:
1, score: 8)
Display of student with lowest score (ID:
1, score: 8) Pass
TC9
Testing the option to exit
This Test Log gives us a detailed view of the test cases, input values and expected results of the program This table helps us to evaluate the performance of the program and detect potential errors in the source code
- Can manage scores of multiple students
- Functions are clearly divided and easy to understand
- There is a loop used to perform the necessary functions of the program many times
2 Disadvantages and difficulties of the program:
Trang 21
3 Future progress improvements:
- Added a feature to check the user input format to avoid errors during data entry
- Initialize arrays to ensure that they contain valid values
Added a feature that allows users to modify or delete student information
- Improved user interface for increased authentication and easier use
About how the procedural setting is applied in your program:
Pros: Functions are clearly demarcated, easy to understand, and easy to reuse Procedural programming is also a good
approach to solving simple and structured problems
Cons: Difficult to manage global variables and often need to pass parameters to the function This can make it difficult to maintain and upgrade the program as the source code becomes larger
The program is easy to use, with a user-friendly menu that guides the user through the various functions available In addition, the code is well-structured and easy to read, with well-defined functions and variable names making it easy to understand the functionality of each component
One of the strengths of this code is its ability to handle input errors, ensuring that the user enters valid input for the student's score This feature improves the reliability and accuracy of the output of the program
Overall, the program is a reliable and effective tool for managing student information and analyzing student learning outcomes Its simplicity and ease of use make it a valuable resource for teachers, students, and anyone else who needs to keep track of student grades