Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2: Read Class Data from a File and Sort (50 points) The file ClassData10

ID: 3699840 • Letter: P

Question

Problem 2: Read Class Data from a File and Sort (50 points) The file ClassData10.txt contains grade information for 10 fictitious students. The file format is • Student Name • 12 Reading Assignment Scores • 8 Homework Scores • Scores for in-class participation, midterm 1, midterm 2, and the final project Using an array of type student info, write a C program that 1. Reads the file information into a 10 element array of type student info. Make sure you update the structure student info from problem 1 to accept 12 reading assignments and 8 homework scores. 2. Calculates the final grades for all 10 students. 3. Print the final scores in order, from highest to lowest. The following functions will sort an array of type int. Modify these functions to use variables of type student info. Your program must make use of the following functions • void Print_Student(student_info X); • void Scan_Student_Info(student_info *S, FILE *fp); void selection(int x[], int size) { // selection sort int i, j; int max; for (i = 0; i < size; i++) { max = i; // start searching from currently unsorted for (j = i; j x[max]) // if found a larger element max = j; // move it to the front } swap(&x[i], &x[max]); } } void swap(int ?x, int ?y) { int temp; temp = ?x; ?x = ?y; ?y = temp; } Sample Code Execution: Red text indicates information entered by the user Grade information for Sarah Zybooks Scores = [9, 2, 5, 6, 3, 8, 9, 8, 3, 10, 10, 1] Homework Scores = [93, 95, 95, 92, 94, 96, 92, 94] In-class Participation Score = 94 Midterm Scores = [95, 98] Final Project Score = 93 Calculated Percentage = 91.23 The Final Grade for Sarah is A Grade information for Lily Zybooks Scores = [10, 1, 10, 7, 6, 8, 0, 10, 5, 4, 7, 4] Homework Scores = [87, 85, 100, 89, 81, 88, 83, 84] In-class Participation Score = 95 Midterm Scores = [99, 90] Final Project Score = 98 Calculated Percentage = 89.74 The Final Grade for Lily is B Grade information for David Zybooks Scores = [9, 4, 10, 5, 6, 10, 8, 1, 2, 2, 9, 4] Homework Scores = [82, 78, 96, 93, 84, 86, 85, 100] In-class Participation Score = 90 Midterm Scores = [94, 91] Final Project Score = 98 Calculated Percentage = 88.98 The Final Grade for David is B Page 3 Grade information for Sydney Zybooks Scores = [9, 2, 4, 10, 2, 5, 8, 7, 3, 6, 10, 3] Homework Scores = [72, 82, 100, 82, 80, 88, 95, 33] In-class Participation Score = 95 Midterm Scores = [96, 93] Final Project Score = 99 Calculated Percentage = 87.30 The Final Grade for Sydney is B Grade information for Jennifer Zybooks Scores = [6, 4, 9, 4, 9, 10, 9, 7, 3, 3, 4, 10] Homework Scores = [85, 33, 94, 90, 85, 84, 87, 92] In-class Participation Score = 100 Midterm Scores = [94, 88] Final Project Score = 94 Calculated Percentage = 86.68 The Final Grade for Jennifer is B Grade information for Scott Zybooks Scores = [8, 9, 10, 5, 0, 4, 0, 10, 5, 6, 1, 9] Homework Scores = [81, 82, 39, 90, 88, 88, 91, 45] In-class Participation Score = 100 Midterm Scores = [100, 94] Final Project Score = 96 Calculated Percentage = 86.33 The Final Grade for Scott is B Grade information for Natalie Zybooks Scores = [4, 10, 7, 6, 1, 3, 10, 9, 2, 9, 10, 4] Homework Scores = [93, 97, 30, 94, 38, 94, 93, 91] In-class Participation Score = 90 Midterm Scores = [93, 99] Final Project Score = 90 Calculated Percentage = 85.68 The Final Grade for Natalie is B Grade information for Joshua Zybooks Scores = [4, 0, 9, 9, 1, 3, 3, 7, 6, 2, 1, 0] Homework Scores = [94, 85, 84, 89, 82, 95, 90, 94] In-class Participation Score = 50 Midterm Scores = [97, 91] Final Project Score = 97 Calculated Percentage = 85.44 The Final Grade for Joshua is B Grade information for Emily Zybooks Scores = [1, 4, 4, 5, 10, 9, 8, 9, 4, 2, 1, 10] Homework Scores = [100, 85, 65, 98, 99, 32, 72, 81] In-class Participation Score = 100 Midterm Scores = [98, 97] Final Project Score = 85 Calculated Percentage = 84.78 The Final Grade for Emily is B Grade information for Megan Zybooks Scores = [5, 4, 8, 0, 9, 0, 0, 7, 2, 4, 10, 7] Homework Scores = [88, 81, 64, 84, 91, 85, 92, 90] In-class Participation Score = 100 Midterm Scores = [91, 96] Final Project Score = 85 Calculated Percentage = 84.28 The Final Grade for Megan is B Goodbye

Explanation / Answer

Hi friend, Its very difficult to read your Questions.

Its like a pragraph.

Please repsot with correct formatting.

Please find my simple program:

#include<stdio.h>
#include<string.h>
#define SIZE 10

typedef struct Student_Type{
char name[30];
int RAss[12];
int HmWork[8];
int in_class;
int mid1;
int mid2;
int final;
char grade;
double percent;
}student_info;

void scan_student_info(student_info *s,FILE *fp){
if(fp == NULL){
  printf(" File Opening error check input file");
  exit(0);
}
int i,j;
double zy = 0;
double tot = 0;
for(i = 0;i<SIZE;i++){
  tot = 0;
  fscanf(fp,"%s",&s[i].name);
  if(feof(fp)){
   break;
  }
  for(j = 0;j<12;j++){
   fscanf(fp,"%d",&s[i].RAss[j]);
  }
  for(j = 0;j<8;j++){
   fscanf(fp,"%d",&s[i].HmWork[j]);
   tot += s[i].HmWork[j];
  }
  fscanf(fp,"%d",&s[i].in_class);
  fscanf(fp,"%d",&s[i].mid1);
  fscanf(fp,"%d",&s[i].mid2);
  fscanf(fp,"%d",&s[i].final);
  tot += s[i].in_class;
  tot += s[i].mid1;
  tot += s[i].mid2;
  tot += s[i].final;
  tot = tot/12.0;
  s[i].percent = tot;
  if(tot >= 90){
   s[i].grade = 'A';
  }else if(tot >= 80){
   s[i].grade = 'B';
  }else if(tot >= 70){
   s[i].grade = 'C';
  }else if(tot >= 60){
   s[i].grade = 'D';
  }else if(tot >= 50){
   s[i].grade = 'E';
  }else{
   s[i].grade = 'F';
  }
}
for(i;i<SIZE;i++){
  s[i].percent = -1;
}
}

void swap(student_info *s1,student_info *s2){
student_info temp;
int i;
temp.final = s1->final;
temp.grade = s1->grade;
for(i = 0;i<12;i++){
  temp.RAss[i] = s1->RAss[i];
}
for(i = 0;i<8;i++){
  temp.HmWork[i] = s1->HmWork[i];
}
temp.percent = s1->percent;
strcpy(temp.name,s1->name);
temp.mid1 = s1->mid1;
temp.mid2 = s1->mid2;
temp.in_class = s1->in_class;
s1->final = s2->final;
s1->grade = s2->grade;
s1->mid1 = s2->mid1;
s1->mid2 = s2->mid2;
strcpy(s1->name,s2->name);
s1->in_class = s2->in_class;
s1->percent = s2->percent;
for(i = 0;i<12;i++){
  s1->RAss[i] = s2->RAss[i];
}
for(i = 0;i<8;i++){
  s1->HmWork[i] = s2->HmWork[i];
}
s2->final = temp.final;
s2->grade = temp.grade;
s2->mid1 = temp.mid1;
s2->mid2 = temp.mid2;
strcpy(s2->name,temp.name);
s2->in_class = temp.in_class;
s2->percent = temp.percent;
for(i = 0;i<12;i++){
  s2->RAss[i] = temp.RAss[i];
}
for(i = 0;i<8;i++){
  s2->HmWork[i] = temp.HmWork[i];
}
}

void selectionSort(student_info *s,int size){
int i,j;
int max;

for(i = 0;i<size;i++){
  max = i;
  for(j = i;j<size;j++){
   if(s[j].percent > s[max].percent){
    max = j;
   }
  }
  swap(&s[i],&s[max]);
}
}

void print_student(student_info *s){
int i,j;
for(i = 0;i<SIZE;i++){
  if(s[i].percent != -1){
   printf(" Grade Information For %s",s[i].name);
  printf(" ZyBooks Scores = [");
  for(j = 0;j<12;j++){
   printf("%d",s[i].RAss[j]);
   if(j != 11){
    printf(", ");
   }else{
    printf("]");
   }
  }
  printf(" HomeWork Scores = [");
  for(j = 0;j<8;j++){
   printf("%d",s[i].HmWork[j]);
   if(j != 7){
    printf(", ");
   }else{
    printf("]");
   }
  }
  printf(" In-Class Participation Score = %d",s[i].in_class);
  printf(" Mid-Term Scores = [%d, %d]",s[i].mid1,s[i].mid2);
  printf(" Final Project Score = %d",s[i].final);
  printf(" Calculated Percentage = %0.2lf",s[i].percent);
  printf(" The Final Grade For %s is %c ",s[i].name,s[i].grade);
  }
}
}

int main(){
FILE *fp;
student_info stu[SIZE];
char file[30];
printf(" Enter The File name To Scan Student info : ");
scanf("%s",&file);
fp = fopen(file,"r");
scan_student_info(stu,fp);
selectionSort(stu,SIZE);
print_student(stu);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote