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

I need help for this C++promgra. If your program is helpful and not complete I w

ID: 3567753 • Letter: I

Question

I need help for this C++promgra. If your program is helpful and not complete I will still give you a good rate. Pleases help me I need a idea to set up it. I jhave the file in my computer. You just need set up it.

Write a program to complete the following tasks. Record all results to a data file called "GradeSheet.dat".

(1) Read the grade sheet from attached data file, "Assignment4.dat". Print the original grade sheet.

(3) Write a module to sort array GRADE[] and print the sorted grade sheet.

(4) Write a module to sort array NAME[] and print the sorted grade sheet.

(5) Write a module to sort array ID[] and print the sorted grade sheet.

(6) Write a module to print the student's id, name, and grade for student with highest grade and with lowest grade, respectively.

(7) Write a module to determine mean of the grades.

(8) Write a module to list students with grade is less than mean.

Explanation / Answer

#include<iostream>

#include<fstream>

#include<algorithm>
using namespace std;
struct student // structure student to store deatils from file
{
   char grade;
   string name;
   int id;
}s[100];
int size=0;
void sortgrade()
{
   for(int i=0;i<size;i++)
       for(int j=0;j<size-i-1;j++)
       {
           if(s[j].grade>s[j+1].grade)
           {
               student temp;
               temp=s[j];
               s[j]=s[j+1];
               s[j+1]=temp;
           }
       }

       cout<<" Sorted by Grade ";
   cout<<"ID Name Grade ";
   for(int i=0;i<size;i++)
   cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
}
void sortname()
{
   for(int i=0;i<size;i++)
       for(int j=0;j<size-i-1;j++)
       {
           if(s[j].name>s[j+1].name)
           {
               student temp;
               temp=s[j];
               s[j]=s[j+1];
               s[j+1]=temp;
           }
       }
       cout<<" Sorted by Name ";
   cout<<"ID Name Grade ";
   for(int i=0;i<size;i++)
   cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
}
void sortid()
{
   for(int i=0;i<size;i++)
       for(int j=0;j<size-i-1;j++)
       {
           if(s[j].id>s[j+1].id)
           {
               student temp;
               temp=s[j];
               s[j]=s[j+1];
               s[j+1]=temp;
           }
       }
       cout<<" Sorted by Id ";
   cout<<"ID Name Grade ";
   for(int i=0;i<size;i++)
   cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
}
void grade()
{
   int i=0;
   cout<<" Highest grade students";
   while(s[i].grade==s[0].grade)
   {
       cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
       i++;
   }
   i=size-1;
   cout<<" Lowest grade students";
   cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
   while(s[i].grade==s[size].grade)
   {
       cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
       i--;
   }
  
}
char grademean(char a)
{
   int avg;
   for(int i=0;i<size;i++)
   {
       avg=avg+s[i].grade;
   }
   avg=avg/size;
   a=avg;
   cout<<" Mean Grade:"<<a;
   return a;
}
void lessgrade(char a)
{
   cout<<" students less than mean Grade: ";
   for(int i=0;i<size;i++)
   {
       if(s[i].grade>a)
           cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
   }
}
int main()
{
   ifstream file;
   file.open("Assignment4.dat"); // opening file
   while(!file.eof()) // reading contents from file to struct s
   {
       file>>s[size].id>>s[size].name>>s[size].grade;
       size++;
   }
   size--;
   cout<<"Original data ";
   cout<<"ID Name Grade";
   for(int i=0;i<size;i++)
   cout<<" "<<s[i].id<<" "<<s[i].name<<" "<<s[i].grade;
   sortname(); //sort by name
   sortid(); //sort by student id
   sortgrade(); // sort by grade
   grade(); // to find highest and lowest grades
   char a=grademean(a); // to find mean grade and is stored in character a
   lessgrade(a); // to find students less than mean grade
   return 0;
}

Assignment4.dat

234 Jubin A
342 Sumath A
341 Thomas B
112 Raj C
543 John D
432 Miller B
564 Jason A
034 Justin B
022 Brad A
045 Tom C

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