Question: CLASS GRADE COMPUTING SYSTEM : Use C language. Mandatory file names: 1) labmain.c will hold main() and no other functions. 2) lab.h will hold any
CLASS GRADE COMPUTING SYSTEM: Use C language.
Mandatory file names: 1) labmain.c will hold main() and no other functions.
2) lab.h will hold any local typedefs or struct definitions, function prototypes, etc. NO VARIABLES that allocate space can be declared here.
3) you must have an additional file name for every function that you write. (e.g. insert_node.c, delete_node.c, option1.c, option2.c, etc.)
You will write a program to access, process and store data in order to calculate grades for a class.
The program will execute in the following format:
lab filename1 filename2
where lab is the name of the executable
filename1 is the data file that contains the current class records to read in from disk
filename2 is a data file that your program will create with the updated class records
This means that you will have to read two parameters from the command line. The two parameters can be the same filename, so you will have to close filename1 before opening filename2 to insure that you do not end up with corrupted data.
You will be supplied with a test class grade file called class_records. All of the data for the students in the class grade computing system will be in this file. Once the program has read in the student data, a user will be able to select options related to what to do with the data. You do not know the number of different students which will be in the file, so your code must be able to deal with an indeterminate number of different students (up to the limits of memory). If any grade slot does not have a current valid score, its value will be -1.
Sample of input:
Quizzes Midterms Homework Final
Brunilda Gassner
12764
0 87.5 90
88.5 93.1 -1
80.62 89.3 96.7
93 -1 -1
Madalene Kelch
11929
90 93.8 85
85.5 91.6 -1
96.12 84.5 77.6
102 -1 -1
Filiberto Callison
12178
90 81.3 70
89.3 89.3 -1
96.12 87.5 89.5
87 -1 -1
First, your program should open the file specified by the filename1 parameter and read in the initial class records. There will be options for adding or deleting students provided to the user later by the program after the initial data is read in and used to build the linked list. The data will be entered in the following format, with each item of data listed entered on a different line:
->A single line with 4 alphanumeric strings separated by spaces specifying the names of the 4 Grade Categories.
Then for each student:
1. Student Name (Assume the name may contain white spaces; check the initial class_records file on Piazza)
2. Student ID number (1 - 20000)
3. 3 Scores for Grade Category1 (3 floating point values separated by spaces)
4. 3 Scores for Grade Category2 (3 floating point values separated by spaces)
5. 3 Scores for Grade Category3 (3 floating point values separated by spaces)
6. 3 Scores for Grade Category4 (3 floating point values separated by spaces)
Data about each student will not be separated from the data for the following student; that is, the first line of input for the next student will immediately follow the student which precedes it on the following line. The end of the input for the students will be indicated when an fscanf() function returns EOF. There will be data about at least one student in the file. The linked list that your program builds for the students should store them in order of increasing student ID number; the students will not necessarily appear in the input in this order.
While reading the input data, and constructing the linked list, for each student your program should:
Calculate the cumulative score for each category (omitting any score listed as -1 from the calculation). If all individual scores are -1, then mark the category cumulative score as -1.
Examples:
If the scores 95 88 89, then add the three scores and divide by 3.
If the scores are 95 88 -1, then add the first two scores and divide by 2.
If a category has the scores 95 -1 -1, then the cumulative score is 95.00.
Calculate the Current grade based on the following weighting system: Category 1 cumulative = 15% of the grade, Category 2 cumulative = 30% of the grade, Category 3 cumulative = 20% of the grade and Category 4 cumulative is 35% of the grade. If any category cumulative score is -1, then use a score of 100 in this calculation.
All Final Grades should be set to -1 when reading in data.
After reading the input data, and constructing the linked list, your program should:
1. Tell the user that the student data has been read in from the file and how many student records were read in.
2. Prompt the user to select from the following options for processing of the data. (REQUIRED: Use an Array of Function Pointers to call the Users Choice of Function for options 1 through 7. It is my expectation that options 1 through 7 will be able to return the same type and that the parameter(s) passed can be made to be identical.)
OPTIONS:
1. Print a single student record with all stored information along with the calculated scores. The student record is requested by student ID number; if you see a score is listed as -1, print n/a. Format it in a readable manner. All information for a single student should fit on a single line. You may want to print out a line with column headers on it prior to printing out the data.
2. Print a single student record with all stored information along with the calculated scores. The student record is requested by student last name; (This function will likely require using the substr() C Library function. If you see a score is listed as -1, print n/a. Format it in a readable manner. All information for a single student should fit on a single line. You may want to print out a line with column headers on it prior to printing out the data.
3. Print all student records with all stored information along with the calculated scores sorted by student ID number; if you see a score is listed as -1, print n/a. Format it in a readable manner. All information for a single student should fit on a single line. You may want to print out a line with column headers on it prior to printing out the data. Include with this data a summary line that lists the average score for each category across all students and an average
4. Recalculate all of a single students grades (assume that new scores have been entered since the last calculation) and print out the students name, the four current cumulatives by category and their current overall grade. The student will be selected by student ID number.
5. Recalculate all students grades (assume that new scores have been entered since the last calculation) and print out each students name, the four current cumulatives by category and their current overall grade.
6. Insert a new score for a single student ID #. You will need to ask which category its for and whether it should be stored in the first, second or third score position.
7. Calculate Final Grades. Calculate the final grade and store it in the appropriate spot for each student. The final grade should be calculated based on the following weighting system: Category 1 cumulative = 15% of the grade, Category 2 cumulative = 30% of the grade, Category 3 cumulative = 20% of the grade and Category 4 cumulative is 35% of the grade. If any category cumulative score is -1, then use a score of 0 in this calculation. Then call option 5 from here to print out all student information. NOTE that this calculation is different than the calculation for Current Cumulative Grade.
8. Add a new student to the class. You will have to prompt for each data item.
9. Delete a student (prompt the user to enter a student ID number to delete): if the student is not found in the linked list, print a message indicating an error, or if the list is empty, print an error indicating that);
10. Exit the (This option would write all current records in the linked list out to disk using filename2 from the command line and would also free all dynamically allocated memory.) The information that you save in filename2 should be able to be used as input to this program the next time it is executed.
The user will enter a choice of one of these ten options by entering 1 - 10 immediately followed by enter (new line). You can assume that all user input will be correct, except that the user may inadvertently attempt to delete a student which has not been added to the class. You should write a separate function to do the necessary computations and print output for each of these options. Some of these functions may call some of the other functions. The goal is to make main() as small and succinct as possible, while creating functions that make it as easy as possible to monitor, modify and execute the code. You should also write a separate function to read the data for a single student from stdin into a node after allocating storage for the node.
GUIDANCE
1. All function prototypes should be included in your lab.h file.
2. Declare the structs shown below in your lab.h file:
struct Cat_Grade{
float score1;
float score 2;
float score3;
float Cumulative;
};
struct Data {
char student_name[40];
int student_ID;
struct Cat_Grade Cat1;
struct Cat_Grade Cat2;
struct Cat_Grade Cat3;
struct Cat_Grade Cat4;
float Current_Grade;
float Final_Grade;
};
typedef struct Node {
struct Data Student;
struct Node *next;
} Node;
You should write and debug the following functions first:
main() (adding items as needed)
create your Makefile (adding items as needed)
a function to read in the student data from disk which may call other functions
a function to print the nodes in the list (i.e. student list; find and carefully follow the sketch of the algorithm in the class slides or from the text on linked lists
a function insert(), to add a node to the list; find and carefully follow the sketch of the algorithm in the class slides or from the text.
a function delete(), to remove a node from the list
DO NOT WRITE THE CODE FOR OTHER FUNCTIONS UNTIL THE FUNCTIONS ABOVE ARE WORKING!!!
Until you are ready to write the code for the other functions, you can write stub functions with empty parameters and empty blocks for the other functions in the program; if these functions are called in the program, they will do nothing, so this will create no problems for testing and For example, a stub function for change_grade() might look like this:
void change_grade(){
return;
}
You can change the return value and the number and type of parameters passed when you have a better idea of what it will require later in your development cycle.
Requirements:
1. The student data must be stored in a singly-linked list, where each node in the list contains the data for one student. The head of the list cannot be a NODE, it must be a list head (e.g.NODE *)
2. You are not permitted to declare any variables at file scope; you should, however, declare the Node type used to store the data for the linked list at file scope (but no variables can be declared as part of this declaration). See the description of the declaration of the Node type above.
3. All floating point data will be entered with up to two digits of precision and should also be output with two digits of
4. You must allocate the storage for each Node structure
5. If a student record is deleted, you should call free() to free the storage for the
6. You must write the student data to disk (filename2) and then free the space for the individual nodes that still contain data before the program terminates when the user selects option 10.
7. You must create a Makefile that creates your executable lab. Insure that the Makefile contains all appropriate dependencies.
all:mkprog
mkprog:mkmain.o mkfact.o mkhello.o
gcc mkmain.o mkfact.o mkhello.o -o mkprog
mkmain.o:mkmain.c mkfunc.h
gcc -ansi -pedantic -c mkmain.c
mkfact.o:mkfact.c mkfunc.h
gcc -ansi -pedantic -c mkfact.c
mkhello.o:mkhello.c mkfunc.h
gcc -ansi -pedantic -c mkhello.c
clean:
rm -rf *.o mkprog
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
