











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
pass pass pass pass pass pass pass pass pass pass pass pass
Typology: Assignments
1 / 19
This page cannot be seen from the preview
Don't miss anything!












Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Prog 102 : Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Dinh Xuan Truong Student ID GCH Class GCH0908 Assessor name Nguyen Tran Dinh Long 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 Truong Grading grid P1 P2 P3 M1 M2 D
Grade: Assessor Signature: Date: Lecturer Signature:
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. In assignment 1, I wrote a small program about managing student grades. And now I make this report for the purpose of detailed analysis of my program with pictures, tables, footnotes, and specific explanations.
According to the curriculum, I used C++ language.
After initialize and declare, I started create 5 functions with void functions:
In here, I used ‘i+1’ because ‘student’ never be student number ‘0’. It always starts from first student. Print to screen “Enter name: “to let user enter information of students. May can use scanf(%[^/n]s) but I use gets because it’s brevity.
To errors that show up like this, using fflush(stdin) to clear cache. The problem will be sloved. I use while-loop structure in here, if grade less than 0 and more than 10, it will force the user to re-
enter IDs. print “ID: “to screen to let user enter information.
Then, after we got the highest score, we also need to find ID of student have highest score. After ‘max’ have new value proportional with grade[i], so it also proportional with id[i] from array[i]. Example grade[2] proportional to id[2]. Print highest score and Id student in if structure.
Similar to find highest score. I used for-loop structure to get grade that had input in “Input information”. Create an integral type of variable that is initialized to the highest possible value. We will call this value "min". Fill the array with the data that you need. Iterate through the array. For each element, compare it to "min". If "max" is raiser than the element of the array, assign temp that specific element of the array.
Then, after we got the lowest score, we also need to find ID of student have lowest score. After ‘min’ have new value proportional with grade[i], so it also proportional with id[i] from array[i]. Print highest score and Id student in if structure.
I set float average to calculate the average score, also same structure with grade. Using for-loop structure to calculate average. After user enter grades of students, total of student will be added together and stored in average variable. Casting integer n to real number. Formula for average score is sum of grades divide by total of students. After created 5 void functions, next, I used it for main functions:
Firstly, I used while-loop structure to check total of student. If user enter less then 3 students or more than real total students of teacher’s class (in topic), user must enter again. After user enter right, it will save in variable n. I warned user that need to use case 1 first because if case 1 has information, then another case can be used. There is menu manage student’s grade. After enter user choice, choice variable will be used for switch- case structure to make menu can be work.
Case 1 is mandatory, run Inputinfo() function, after that, assign check=true and return to the menu.
If user choose case 2, it will run Showinfo () function, it happens if user input case 1 first. Or not, it will print to screen “You must input information first.” To make it work, I used if-else structure to control it. Finish case 2 , return to the menu.
When user choose case 3, system will calculate and find ID student with highest score by Highest () function. Then, return to the menu. Case 4 will be used to show ID student with lowest score by Lowest () function. Case 5 will calculate and show average of grade’s students by average () function.
this problem happens when user did not input information first c) Show information d) Find student have highest score e) Find student have lowest score f) Calculate average of grade’s student
Test case What’s being test How Data Expected result Actual result Evaluate 1 Input total of students Try to input boundary data, typical data, and bad data Letters; characters (a, b, @, $,...) Invalid choice Error program Fail Typical data Data accepted Data accepted Pass Decimal data Invalid choice Invalid choice Pass Boundary data Invalid choice Invalid choice Pass 2 Input IDs Try to input boundary Letters; characters (a, b, @, $,...) Invalid choice Error program Fail
To me, after I created a program that manage grade’s student, I understood how to write a small program useful, despite it’s not enough function, structure and code is not really clearly. But in future, I will learn more soft skills and more experience to improve and update my coding skills.