Note: Nếu muốn support C, C#, Networking, Database, project web, 1633, security_zalo 0962.986.805 or fb https://www.facebook.com/profile.php?id=100080073517431. Assignment 2 môn Programing (PROG102) đại học Greenwich 2021. Bài luận đạt điểm chuẩn Merit với trích dẫn học thuật harvard. Dựa vào để hoàn thành điểm M là không khó, full code cũng được xuất hiện trong bài, hoàn toàn sửa thành code của bản thân. Giá tiền phải chăng, dành cho người không có thời gian để làm luận hoặc không có form hướng dẫn. Bạn cũng có thể tìm asm1 của môn này bởi vì mình có đăng trọn bộ. Goodluck
Introduction
Scenario
Create a small, menu-based student grades management application for a math class that lets the teacher enter student IDs (stored in an integer array) and their corresponding grades (stored in a float array) and keeps these records in two parallel arrays The program can print all student IDs with their grades and determine which student has the highest grade and which has the lowest grade It should return to the main menu after completing each option so the teacher can perform another operation, and it must include a quit option to exit the program.
Problem
• The problem of student information management is a difficult problem
Manual management method has many disadvantages.
• I need to find a way to program and create a system that solved the disadvantages of the old method.
• The program should have the main functions needed to enter, print, calculate min, max, average, exit, …
Solution
• Using procedural programming to write programs.
• The program needs an interface to select functions, variables and array to enter information: name, ID, age, gender, subject scores.
• Create separate functions for input, print, find the highest and lowest scores, average score, result, rank, rating, exit.
Implementation
Explain about structure of program
: Provide the ability to enter Use printf, scanf, …
: Adjust a variety of characters (char)
: Perform math operations, transformations, ordering, …
: Use it to use getch(), …
This section declares a variable stu to store variables related to student information.
Inside, I declare variables to store information:
+math, English, prog, average: points
Thanks to the struct structure, I can use the information easily even though there are many students.
- The next is declaring functions.
At here, I declare all of functions.
I write a loop to know the limit of number of students, declare an empty array of structure stu.
Program interface and switch-case for selecting functions are also created here.
Within functions are functions applied.
This is the place to write the functions, which will be used in main.
Explain about each function
- This function is used to enter student information: ID, name, age, gender, grades of 3 subjects.
- I use printf to request information from the user.
- With variables of type int, float, I use scanf to save the parameter to the variable.
- With variables of type char, I use gets to store the parameter in the variable.
- I use fflush(stdin); to clear the program’s temporary memory so that there are no garbage values.
This function is used to store student information as an element in an array so that it can be easily used.
void two(stu u[], int o) declares a function named two that takes an array u of the struct stu and an integer o indicating the number of students to process Inside, the loop for (int i = 0; i < o; i++) iterates over each element, printing "Enter student %d" with i+1 to show the current student index, and then calls the one function to input information for u[i] This setup ensures all o students are entered sequentially Table 1 explains the function two.
This function is used to print all information like ID, name, age, gender, scores of student.
Take as input the variables ss of structure stu Use printf to print all the information to the screen: ID, age, gender, grade of 3 subjects Use %d,
%.1f, %s with variables to get information.
This function prints student information and mirrors the behavior of the 'two' function; instead of using the 'one' function for input, it uses the 'three' function to display the data.
This function is used to calculate average I use for loop to get the scores information from the array Recipe: average= total of 3 scores (math, English, prog) divided 3.
This function is quite long, it has the function of calculating the highest and lowest points.
Find max in an array by initializing a float max variable to the average of the first element in the array, which makes it easy to compare with the second value Use a loop to inspect the subsequent elements, and if max < average, assign max = average This method tracks the larger value as you progress and ignores smaller ones, and this sequence of commands finds the maximum value in the array.
• Find min: Use the same algorithm as finding max Initialize min variable instead of max variable In the If statement, compare min > average.
• Finally I continue to use a loop to print the maximum and minimum points In addition, I also print the average score of all students.
This function prints "Passed" or "Failed" by iterating through an array with a loop It uses an if statement to compare each item's average to 5 (average >= 5) If true, it prints the ID and name with a "passed" status; if false, it prints the ID and name with a "failed" status This simple decision logic determines the final outcome for each entry and presents a clear pass or fail result based on the average score.
This function is used to print out rank of students Initialize a variable HD of stu.
Use loop 1 with i=0 and condition i