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

Please help me. Use comments to understand the coding for this project. Use stru

ID: 3822341 • Letter: P

Question

Please help me. Use comments to understand the coding for this project. Use structures correctly. C++ programming. Make sure the output matches the sample output given below. Thank you!

Programming Assignment #3: Student CS Grade Database Description: This program will read a data file that will contain students' scores for 5 Computer Science (CS) tests. Each student record will contain his her last name, first name, numeric student ID, student username, 5 test scores, average for these five scores, and grade for CS course. The file will be processed by the program and will produce a report The report contains seven parts 1) The students' usernames 2) The average score for each student's five tests 3) The grade for each student's CS course. 4) The average CS scores for the class. 5) The total number of students with grades A. B. C. D. and F 6) The sorted student names and IDs based on user choice: descending or ascending order of grades. 7 Search a student grade by entering student user name ID (See the attached sample input and output for example.)

Explanation / Answer

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstring>

int main()

{
fstream infile("grade.dat",ios::in);
if(!infile){cerr<<"file could not be found!";exit(1);}

fstream outfile("Output.txt",ios::out);
if(!outfile){cerr<<"file could not be created!";exit(1);}


char lname[20];
char fname[20];
       int ID;
       char username[20];
       int Test1;
       int Test2;
       int Test3;
       int Test4;
       int Test5;
       int Total_Tests;
       double avg=0;
int grades;
char c;
int lines=1;
  

while(infile.get(c))
{if(c==' ') lines++;}
infile.clear();
infile.seekg(0);

for(int k=0;k<lines;k++)
{
infile>>fname;
infile>>lname;
               infile>>Test1
               infile>>Test2
               infile>>Test3
               infile>>Test4
               infile>>Test5
               String fname_array[]=fname;
String lname_array[]=lname;
               String username[]=strcat(lname_array[1],strcat(fname_array[1],ID)
outfile<<fname<<" "<<lname<<" "<<ID<<" "<<username[]<<" "<<Test1<<" "<<Test2<<" "<<Test3<<" "<<Test4<<" "<<Test5;
              
int sum=0;
for(int i=0;i<8;i++)
{
if(infile>>Total_Tests)
{sum+=Total_Tests;
outfile<<Total_Tests<<" ";}
}

outfile<<(double)sum/8.0<<endl;
               if (sum >= 0)
       if (sum >= 60)
           if (sum >= 70)
               if (sum >= 80)
                   if (sum >= 90)
                       if (sum > 100)
                       cout<< "Grade can not exceed 100" << endl;
                       else
                       outfile << "A" << endl;
                   else
                       outfile << "B" << endl;
               else
                   outfile << "C" << endl;
           else
               outfile << "D" << endl;
       else
           outfile << "F" << endl;
   else
       cout << "Grade can not be a negative number" << endl;
}


system("pause");
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