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

New Requirements You are to implement a Studentlist data structure/data type tha

ID: 3873516 • Letter: N

Question

New Requirements You are to implement a Studentlist data structure/data type that stores players using an internal array of Student in the class. Add Students to the List as they come in from the data file. You will need to add the class Studentlist. The maximum number of students in a list is 25 You must implement the following operations on your StudentList along with any other utility functions you might need. You may also need to add operations to the class Student to encapsulate i/o operations to the class. Operations for Studentlist .Default Constructor Add a Student to the List- add items in the order they were found in the file. No sorting is necessary in this version of the program, lterate through the List so that you can get each student out for printing . getClassAverage . Clear out the list to make it empty . Test if a list isFull Get the size of the list New Operations for Student Add a method (read) that lets a student object read its data from an input stream. NOTE THAT THERE IS NO LONGER a -1 at the end of a set of grades!! You must determine whether xou are Example: studentl.read(inputfile);

Explanation / Answer

#include<iostream>

#include<fstream>

#include <iomanip>

#include<stdlib.h>

#define SIZE 25

using namespace std;

//Class Student definition

class Student

{

public:

//Data member

string fName, lName;

double test[3], homeWork[5];

double avg;

//Constructor

Student();

//Function to read data from file

void Input(Student s_DB[], int &count);

//Function to write data to file

void Output(Student s_DB[], int &count);

};//End of class

//Default constructor

Student::Student()

{

//Initializes data members

fName = lName = "";

for(int x = 0; x < 3; x++)

test[x] = 0;

for(int x = 0; x < 5; x++)

homeWork[x] = 0;

}//End of constructor

//Read data from file and store it in class object

void Student::Input(Student s_DB[], int &count)

{

//Open file in read mode

ifstream ifile("StudentRecord.txt");

//If file does not exist show error message and exit

if (ifile.fail())

{

cout << " Error!";

exit(0);

}//end of if

//Loops till end of file

while (!ifile.eof())

{

//Read data from file and stores it in respective data members

//Store name

ifile>>s_DB[count].fName>>s_DB[count].lName;

//Store test mark

for(int x = 0; x < 3; x++)

ifile>>s_DB[count].test[x];

//Store homework mark

for(int x = 0; x < 5; x++)

ifile>>s_DB[count].homeWork[x];

//Increase the counter

count++;

//Checks for maximum record

if(count > 25)

{

//Displays error message and stop

cout<<" Cannot add more record. List is full.";

exit(0);

}//End of if

}//End of while

}//End of function

//Writes all student objects information

void Student::Output(Student s_DB[], int &count)

{

//Declares local variables

double testTotal, homeTotal, testAvg, homeAvg, classTotal = 0;

double classAvg = 0;

//Counter for test and homework

int countT, countH;

//Open file in write mode

ofstream ofile("StudentGradeReport.txt");

//Writes heading

ofile<<" Course Grade Report ----- "<<count<<" students enrolled ";

//Loops till number of student records

for(int x = 0; x < count; x++)

{

//Initializes test and homework total to zero for each student

testTotal = homeTotal = 0;

//Initializes test and homework counter to zero for each student

countT = countH = 0;

//Loops for test mark

for(int y = 0; y < 3; y++)

{

//Checks whether the test appeared or not

if(s_DB[x].test[y] != 0)

countT++;

//Calculates the total test mark

testTotal += s_DB[x].test[y];

}//End of loop

//Calculates the test average mark based on the test appeared

testAvg = testTotal / countT;

//Loops for homework mark

for(int y = 0; y < 5; y++)

{

//Checks whether test appeared or not

if(s_DB[x].homeWork[y] != 0)

countH++;

//Calculates the total homework mark

homeTotal += s_DB[x].homeWork[y];

}//End of loop

//Calculates the homework average mark based on the test appeared

homeAvg = homeTotal / countH;

//Calculates student average mark

s_DB[x].avg = (testAvg + homeAvg)/ 2.0;

//Calculates class total average mark

classTotal += s_DB[x].avg;

//Writes data to file

ofile<<" Student Name: "<<s_DB[x].fName<<", "<<s_DB[x].lName;

ofile<<" Recorded Grades: "<<countT<<" tests and "<<countH<<" homeworks.";

ofile<<" Current Average: "<<s_DB[x].avg<<" ";

}//End of loop

//Calculates class average mark

classAvg = classTotal / count;

//Writes data to file

ofile<<" Overall class average is: "<<classAvg;

}//End of function

//Main function

int main()

{

//Creates an array of objects

Student s_DB[SIZE];

//Initializes the counter to zero

int count = 0;

//Call method

s_DB[0].Input(s_DB, count);

s_DB[0].Output(s_DB, count);

}//End of main

StudentRecord.txt file contents

Beth Allen
100 100 100
75 75 85 85 95
Joe Davis
50 85 96
50 50 85 85 99
Reza Albedin
88 88 88
45 45 99 99

StudentsGradeReport.txt file contents


Course Grade Report ----- 3 students enrolled

Student Name: Beth, Allen
Recorded Grades: 3 tests and 5 homeworks.
Current Average: 91.5

Student Name: Joe, Davis
Recorded Grades: 3 tests and 5 homeworks.
Current Average: 75.4

Student Name: Reza, Albedin
Recorded Grades: 3 tests and 4 homeworks.
Current Average: 80

Overall class average is: 82.3

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