In: Computer Science
Dev c++ should be used to answer the question above.
SCIMS at USP wants to maintain student records using linked lists. The school currently offers 3 first-year courses which are CS100, CS101 and CS110. These courses are compulsory and are required by students to do in a semester. All courses have two assignments (20% each ), a mid-semester test (10%) and final exam (50%). The following file contains the students' records, course lists with appropriate marks. Student file contains students id number and name. Each course file contains students mark (assignment 1, assignment 2, MST and final exam). Beside each assessment in the file, the total mark for that particular assessment is given.
Student. Txt
ID Fname Lname
1234 David Dalton
9138 Shirley Gross
3124 Cynthia Morley
4532 Albert Roberts
5678 Amelia Pauls
6134 Samson Smith
7874 Michael Garett
8026 Melissa Downey
9893 Gabe Yu
CS100.txt
ID A1(50) A2(50) MST(30)FE(100)
1234 25 25 20 60
9138 15 30 10 50
3124 30 20 20 80
4532 36 47 30 90
5678 10 10 10 30
6134 45 50 25 20
7874 36 5 10 35
8026 47 2 12 40
9893 35 20 20 56
CS101.txt
ID A1(40) A2(30) MST(20)FE(100)
1234 15 25 20 50
9138 20 30 20 70
3124 40 20 20 80
4532 16 12 10 75
5678 10 10 10 30
6134 25 30 20 20
7874 36 5 10 35
8026 5 22 12 40
9893 35 20 20 56
CS110.txt
ID A1(30) A2(50) MST(30)FE(100)
1234 15 25 20 50
9138 20 30 20 70
3124 40 35 30 80
4532 16 12 10 75
5678 20 30 20 30
6134 25 30 20 20
7874 36 5 10 35
8026 5 22 12 40
9893 35 20 20 56
You are required to write a program for the school to do grade
calculation and analysis using linked lists. The following criteria
need to be used for grade calculation for each course:
Total Score Grade GPA
85 or more A+ 4.5
78 to 84 A 4
71 to 77 B+ 3.5
65 to 70 B 3
56 to 64 C+ 2.5
50 to 55 C 2
40 to 49 D 1.5
0 to 39 E 1
Please do note that if the student does not meet the minimum 40%
mark in the final exam and the course total mark is above 50 then
the student should be given a D grade.
Requirements
1. Draw the structure of the linked list using an appropriate tool
with all relevant data from the file.
2. This problem must be solved using linked list. You have to use
classes to create linked list.
3. The main program should be able to do the following:
Create a linked list for each file and store the records of the
file.
Calculate the total mark and grade of a student for each course
which must be stored in the list.
Create a menu for the user that can do the following:
o Exit program
o Display all students for SCIMS
o Display the marks and grade for each course. The course code will
be entered by the user.
o Display all students who got D grade because the minimum 40% was
not met in the final exam. The display should include student ID,
name, course code, total mark.
o Display all students who failed all three courses.
o Display students in each course who got A+.
o Calculate and display semester GPA for all students. Semester GPA
is calculated by adding GPA for all courses and then divided by the
number of courses.
o Delete a student record from all the linked lists. The program
should prompt the student id number.
o Add a student record in all linked lists.
Except the first menu, all others should be implemented using
functions of the main program.
Dev c++ should be used to answer the question above.
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define NAME_LEN 50
int read_line(char str[], int n);
void insert (int num_students);
void average_finder(int num_students);
void print (int num_students);
struct test_result {
char name[NAME_LEN+1];
int number;
int grade1;
int grade2;
int midterm;
int final;
float numeric;
struct test_result *next;
};
struct test_result *studen = NULL;
int main(void)
{
struct test_result *p;
char code = 'y';
int num_students = 0;
int done = 0;
while(!done) {
switch (code) {
case 'y': insert(num_students);
print(num_students);
break;
case 'n': average_finder(num_students); done++;
return 0;
default: printf("Invalid entry. Try again.\n");
return 0;
}
printf("\nWould you like to enter another record? y(yes) or
n(no)?");
scanf(" %c", &code);
while (getchar() != '\n'); /* skips to end of line */
}
return 0;
}
void insert(int num_students)
{
//int part_number = 0;
struct test_result *p;
p = malloc(sizeof(struct test_result));
printf("Enter the student name: ");
read_line(p->name, NAME_LEN);
printf("Enter the student's grade for quiz #1: ");
scanf("%d", &p->grade1);
printf("Enter the student's grade for quiz #2: ");
scanf("%d", &p->grade2);
printf("Enter the student's grade for midterm: ");
scanf("%d", &p->midterm);
printf("Enter the student's grade for final: ");
scanf("%d", &p->final);
p->numeric = (((p->grade1 + p->grade2) * 1.25) +
(p->midterm * 0.25) + (p->final * 0.50));
}
void average_finder(int num_students)
{
num_students = 0;
struct test_result *p;
int total_quiz1 = 0;
int total_quiz2 = 0;
int total_midterm = 0;
int total_final = 0;
int total_numeric = 0;
float average_quiz1 = 0;
float average_quiz2 = 0;
float average_midterm = 0;
float average_final = 0;
float average_numeric = 0;
total_quiz1 += p->grade1 += num_students;
total_quiz2 += p->grade2 += num_students;
total_midterm += p->midterm += num_students;
total_final += p->final += num_students;
total_numeric += p->numeric += num_students;
average_quiz1 = (double)total_quiz1 / num_students;
average_quiz2 = (double)total_quiz2 / num_students;
average_midterm = (double)total_midterm / num_students;
average_final = (double)total_final / num_students;
average_numeric = (double)total_numeric / (num_students);
printf(" Quiz1 Quiz2 Midterm Final Total\n");
printf("Average %9.1f %9.1f %9.1f %9.1f %9.3f\n", average_quiz1,
average_quiz2, average_midterm, average_final,
average_numeric);
}
void print(int num_students)
{
struct test_result *p;
printf("Name Quiz1 Quiz2 Midterm Final Total\n");
printf("%10s %9d %9d %9d %9d %9.1f\n", p->name, p->grade1,
p->grade2, p->midterm, p->final, p->numeric);
}
int read_line(char str[], int n)
{
int ch, i = 0;
while(isspace(ch = getchar()))
;
str[i++] = ch;
while ((ch = getchar()) != '\n') {
if (i < n)
str[i++] = ch;
}
str[i] = '\0';
return i;
}