#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef struct Student{
char student_id[11];
char student_name[20];
int score;
char grade;
} Student;
typedef struct Node{
Student s;
struct Node *next;
} Node;
//Function to add to linked list
Node add(Node list, Student s){
Node *newNode = (Node*)malloc(sizeof(Node));
newNode->s = s;
newNode->next = NULL;
if(list == NULL)
list = newNode;
else {
Node *ptr = list;
while (ptr->next != NULL)
ptr = ptr->next;
ptr->next = newNode;
}
return list;
}
//Function to return grade based on score
char getGrade(int score){
if(score >= 90)
return 'A';
else if(score >= 80)
return 'B';
else if(score >= 70)
return 'C';
else if(score >= 60)
return 'D';
else
return 'F';
}
//Function to read data from file into linked list
Node readFromFile(Node list){
FILE *f = fopen("student.dat", "r");//Open file in read mode
if(f == NULL){
printf("Error: Unable to open file\n");
exit(EXIT_FAILURE);
}
Student s;
while(!feof(f)){
fscanf(f, "%s %s %d", s.student_id, s.student_name,
&s.score);//Read a record
s.grade = getGrade(s.score);//Get grade based upon score
list = add(list, s);
}
fclose(f);//Close file
return list;
}
//Function to return mean of student scores
double getMean(Node *list){
Node *ptr = list;
int n = 0;
double mean = 0.0;
while(ptr != NULL){
mean += ptr->s.score;
n++;
ptr = ptr->next;
}
mean = mean/n;
return mean;
}
//Function to return standard deviation of student scores
double getStandardDeviation(Node *list){
Node *ptr = list;
double mean = getMean(list);
double sd = 0;
int n = 0;
while(ptr != NULL){
sd += pow(ptr->s.score - mean, 2);
n++;
ptr = ptr->next;
}
sd = sqrt(sd/(n - 1));
return sd;
}
//Function to search linked list for student with student
id
void searchWithStudentID(Node list, char student_id){
Node *ptr = list;
while(ptr != NULL){
if(strcmp(ptr->s.student_id, student_id) == 0){
printf("student_id\tstudent_name\tscore\tgrade\n");
printf("%s\t%s\t\t%d\t%c\n", ptr->s.student_id,
ptr->s.student_name, ptr->s.score, ptr->s.grade);
return;
}
ptr = ptr->next;
}
printf("No such student!\n");
}
//Function to change student score by searching linked list
using student id
void changeScore(Node list, char student_id){
Node *ptr = list;
int score;
while(ptr != NULL){
if(strcmp(ptr->s.student_id, student_id) == 0){
printf("Enter new score: ");
scanf("%d", &score);
ptr->s.score = score;
ptr->s.grade = getGrade(score);
return;
}
ptr = ptr->next;
}
printf("No such student!\n");
}
int main(){
Node *list = NULL;//Create an empty list
list = readFromFile(list);
printf("Mean of student scores: %f\n", getMean(list));
printf("Standard deviation of student scores: %f\n",
getStandardDeviation(list));
printf("\nSearching for student with id 2011710088:\n");
searchWithStudentID(list, "2011710088");
printf("\nSearching for student with id 2011710095:\n");
searchWithStudentID(list, "2011710095");
printf("\nChanging score of student with id
2011710088:\n");
changeScore(list, "2011710088");
printf("\nChanging score of student with id
2011710095:\n");
changeScore(list, "2011710095");
return 0;
}
Sample student.dat file:



please use the c language Assignment 12 The program to write in this assignment is a...
in C porgraming . use #include〈stdio.h〉
#include〈stdlib.h〉
Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and scores are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 2011710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student_id,...
codeblock c++ language
Write a program that reads students test scores in the range 0-200 from a file until end of file (use e of() to check if ifstream reaches the End of File Stream) and store those scores in an array. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100- 124, 125–149, 150-174, and 175–200. Finally, the program outputs the total number of students, each score range...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
THIS IS FINAL COURSE ASSIGNMENT, PLEASE FOLLOW ALL
REQUIREMENTS.
Hello, please help write program in JAVA that
reads students’ names followed by their test scores from
"data.txt" file. The program should output
"out.txt" file where each student’s name is followed by
the test scores and the relevant grade, also find and print the
highest test score and the name of the students having the highest
test score.
Student data should be stored in an instance of
class variable of type...
C++ Write a program that reads the number of students in the class, then reads each student's name and his/her test score. Print out each student name, test score and grade, and the average score of the whole class. The program must use vectors and loops for the implementation. The grades are determined as follows: A >= 90; 80 <= B < 90; 70 <= C < 80; 60 <= D < 70; F < 60.
Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...
Plz help!! The programming
language is C and could you write comments as well?
Problem 2. Calculate Grades (35 points) Arrays can be used for any data type, such as int and char. But they can also be used for complex data types like structs. Structs can be simple, containing simple data types, but they can also contain more complex data types, such as another struct. So you could have a struct inside of a struct. This problem deals with...
In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...
1. Write a program that randomly generates 10 whole numbers between 0 and 100 and stores them into an array. The program then calculates the average and displays the average and the numbers that are above the average. Use loops where needed. Must be stored in an array. Must be done using C++. 2. Write a program that reads 8 student scores, between 0 and 100, finds the best score, and then assigns grades based on the following scheme. Must...
C++ program that reads students' names followed by their test scores (5 scores) from the given input file, students.txt. The program should output to a file, output.txt, each student's first name, last name, followed by the test scores and the relevant grade. All data should be separated by a single space. Student data should be stored in a struct variable of type StudentType, which has four components: studentFName and studentLName of type string, an array of testScores of type int...