1. Trang chủ
  2. » Luận Văn - Báo Cáo

Procedural Programming (PROG102)

22 1 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 22
Dung lượng 877,25 KB

Nội dung

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.

ASSIGNMENT FRONT SHEET Qualification BTEC Level 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 VU THANH TRUONG Student ID GCH211415 Class GCH1108 Assessor name PHAM DANH TUYEN 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 TRUONG  Summative Feedback: Grade:  Resubmission Feedback: Assessor Signature: Date: Lecturer Signature: Table of Contents I Implementation: Explain structure of program: Program function: How the functions are used in the program: 11 Important algorithms in your program: 14 II Program results: 15 Menu: 15 Input information: 15 Display information: 16 Display Highest Score: 17 Display Lowest Score: 18 Exit: 18 III Testing: 19 IV Evaluation: 20 Advantages of the program: 20 Disadvantages and difficulties of the program: 20 Future progress improvements: 21 V Conclusion: 21 I Implementation: 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 to 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 6 + In each iteration, the program will ask the user to enter the student's student number using the cout command Then the value entered will be stored in the id array at position i + After entering the student code, the program asks the user to enter the student's score with the cin command The while statement is used to ensure that the value entered is valid + The student's score is stored in the score array at position i If the entered point value is between k and m (the two previously declared values), the break statement is used to exit the while loop If the input point value is not valid, the program will display an error message and ask the user to re-enter the value + 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 + Finally, after the for loop had ended, the student ID and score information of all the students was entered and stored in the id and score array • 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 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 + Finally, after the for loop has finished, the program displays information about all the students entered and stored in the id and score arrays • Display the student's highest score: findStudentWithMaxScore: This function is used to find the student with the highest score In this function, we use a loop to go through the list of students and find the highest score To this, we use two variables: maxscore and peoplemax The variable maxscore save value of the highest score found in the list and the variable peoplemax save ID of the student with the highest score After finding the highest score, we go through the list of students again to find the students whose scores are equal to the maxscore and display the information of these students + int maxscore=score[1];: This is the declaration of the variable "maxscore" with an initial value equal to the score value of the first student in the list This is the initial initial value to compare with the scores of other students + int peoplemax=id[2];: This is the declaration of the variable "peoplemax" with an initial value equal to the ID value of the second student in the list This is the initial value to compare with the IDs of other students + for(int i=1; imaxscore){ }: This is an "if" statement to compare the score of the "i"th student with the value "maxscore" If that student's score is higher than the "maxscore" value, the "maxscore" value will be updated with that student's score, and the "peoplemax" value will be updated with that student's ID + for(int i=1; i

Ngày đăng: 17/06/2023, 16:22

w