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

Part 1 Write a program which makes a grade book using file i/0.Your program (1)

ID: 3534918 • Letter: P

Question

Part 1

Write a program which makes a grade book using file i/0.Your program

(1) Reads from an input file using file i/o 20 names(can use first names but make them distinct) and the corresponding grades(grades are between 0 and 100- make several with the same grade).

(2) finds the average

(3) finds the mode, the most common grade- use a frequency array.

(4) sorts the names alphabetically using a link list implemented via classes. Each node in the list should have the name, the grade, and a pointer to another node. You will need string comparisons. A selection sort might be the easiest.

(5) Sorts the grades numerically and prints the names and corresponding grade

Divide up the parts of the assignment into functions.

Part 2

Repeat part 1 but rather than using linked lists for 4 and 5, use 2 arrays- one for names and one for grades and the sorting should be done using a merge sort.

Please make it simple as possible! THANK YOU! I APPRECIATE IT!! :)

Explanation / Answer

#include<iostream.h>

#include<fstream.h>

struct hi

{

char name[30];

float grade;

hi *next;

};

void main()

{

hi mem,*ptr,*p,*temp;

fstream file;

file.open("data.txt");

float total=0,avg,max,,a,b,c,i=0,arr[20];

p=start;

while(file!=eof)


{

mem-file.read((*ch)&mem,sizeof(mem));

cout<<"Name "<<mem.name<<" grade="<<mem.grade";

total=total+grade;

i++;

arr[i]=mem.grade;

ptr=new mem;

ptr=mem;

p->next=ptr;

}

avg=total/(i+1);

//sorting

p=start;

while(p->next!=null)

{

ptr=ptr->next;

if(p->grade>ptr->grade)

{

temp=p;

p=ptr;

ptr=temp;

}

p=p->next;

}

p=start;

//print name

while(p->next!=null)

{

cout<<"Name is "<<p->name<<" Grade is "<<p->grade;

}

}







2.


struct hi

{

char name[30];

float grade;


};

void main()

{

hi mem;

fstream file;

file.open("data.txt");

float i=0,arr[20];

char name[20[30];

p=start;

while(file!=eof)


{

mem-file.read((*ch)&mem,sizeof(mem));

cout<<"Name "<<mem.name<<" grade="<<mem.grade";

total=total+grade;

i++;

arr[i]=mem.grade;

name[i]=mem.name;


}


//merge sort


int temp;

char[30];

for(i=0;i<20;i++)

{

if(arr[i]>arr[i+1])

{

temp=arr[i];

arr[i]=arr[i+1];

arr[i+1]=temp;

t=name[i];

name[i]=name[i+1];

name[i+1]=t;

}

}