














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A math teacher wants to manage the grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, students’ 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 the highest grade and lowest grade. Your program should be menu-based with the options above.
Typology: Study Guides, Projects, Research
1 / 22
This page cannot be seen from the preview
Don't miss anything!















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 Nguyễn Tuấn Dương^ Student ID (^) GCH 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 D
I. Introduction.
1. Scenario A math teacher wants to manage the grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, students’ 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 the 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 the program. 2. Problem A teacher wants to manage the grades of a class. You need to write a small application that meets his requirements. He needs to enter student information and store these in separate arrays. Then he needs to print all the student cards along with their grades. Finally, he needs to know which student has the highest score and the lowest score. Your program should have a menu based on the options above. When an option is taken, the program will return to the main menu so that he can choose another option. And there is an option to exit the program. 3. Solution ➢ Step 1: Define the variables and data types needed in the program. ➢ Step 2: Define different selection structures. ➢ Step 3: Define the iteration structure. ➢ Step 4: Divide the program into functions (subfunctions) and draw a hierarchy diagram to illustrate the structure of your program. ➢ Step 5: Create the program:
3. Declare the variable Struct. Structures in C Programming is used in cases where we must group dissimilar data types (int, float, char, etc.). The declarations in the Student struct function:
4. void addStudent (struct student list[100] ) Explain: - Void: used because the student input function does not return a value. - Printf(): print out message lines for users to enter information. - Scanf(): read user numeric input. - Gets(): read user string input. - Fflush(stdin): clear cache. - The function will start with getting the number of students. The function will not stop until all the required information has been entered with a sufficient number of inputs. - Information such as "id" , "name" , "grade" will be saved to serve the following requests.
6. Void findMax( struct student list[100]) Explain: - Void: void is used to determine the biggest point value after being entered in the two previously entered voids. Thereby providing the results according to the user's demand - %o.2f : the result is taken with 2 decimal places after the comma. - The function will receive the first value and scan, if it encounters a bigger value, the function will receive that value and continue scanning. That process will continue until all values are scanned. The result will be the maximum value.
7. int main().
Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.4. Line 93 - 95 Case2: Case uses the void findMax(data) capability. When finished, the case will stop with "break" Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.5. Line 96- 98 Case uses the void findMin(data) capability. When finished, the case will stop with "break" Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.6. Line 99- 101 Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop. Exit(0): Exit the program. 7.7. Default
III. Program results.
1. The program starts running 2. In case you choose options other than 1 and 0, the program will return to “Menu” In case you select other options greater than 6, the program will print an error message and ask to re-enter: “incorrect number. Choose again, please!” After that, the program will return to ”Menu”
Next, you will need to enter each student's information in the required form. After you have entered all the information of the students, the program will return to the “Menu”.
4. Selection 2. In case you choose option 2, the program will print out the information sheet of the students and return to the “Menu”
IV. Evaluation.
1. Program advantages. Let us begin by discussing the program's benefits. In general, the built software has satisfied the scenario's aims and, of course, the user's requirements (teachers). To begin, we solved the problem using procedural programming. To cope with which apps are, break down the burden into different functions. For testing and debugging, we employed the program's standalone features. As a result, the functions have been divided into parts. The design is scientifically presented, simple to comprehend, and simple to implement. Furthermore, the app contains a slew of features that are tailored to the user's needs. 2. Program limitations. Aside from the benefits listed above, the scheme has several flaws that must be addressed. The first is that for the application to operate, users will need to enter a lot of data, which may be quite inconvenient if the wrong data is entered. Second, if you don't correct the incorrect student data tomorrow, the application will continue to run and save the incorrect data until you correct it. Third, if you run the function to sort students' scores from high to low, the variables' locations will change, resulting in inaccurate information about the students with the highest and lowest scores if you run it again. Finally, if the user wishes to use the function to discover information about students by name, they must input all of the students' names that have been saved correctly, otherwise, the computer will state that no information about them was found.
3. Solution to the problem. To address the above problems, we have several rather effective and simple-to- implement remedies. Firstly, we may construct a separate function in the program called Modify student information. We may combine removing student information, modifying student information, and adding student information in this function. If a mistake is made, this method will make it easy to re-enter or modify student information. Secondly, after utilizing the student sort function, we may construct a piece of code that returns the values' original positions to avoid misplacement. Thirdly, when it comes to locating student information by name, we may create a program that searches just for continuous characters or a portion of the name. Searching will be faster and easier with this solution.