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

using c++ Must use Class specification (.h). Class implementation (.cpp). Create

ID: 3607130 • Letter: U

Question

using c++

Must use Class specification (.h). Class implementation (.cpp).

Create arrays of class objects for 15+ student records including student ID’s, student names, pointers point to each of student’s test scores, and the average of each student’s test scores.

A. The student records must be in a file for input including students ID’s, and student names. The file path in the desktop can be located by file property, for example:“C:\Users\yourUsersName\Desktop\filename.txt”

B. The 10 testScores of each student may be initialized in the program body or stored in a second file for input.

C. After inputting the file into arrays of class objects, calculate the average score of each student. The call function for average must be a member function of the student class.

D. Print out student ID’s, student names, average scores and the associated 10 testScores of each student.

E. Your class declaration should include student records as member data of the class. Your function definition should include the average function and other functions as you desire as member functions of the class.

Must use class specification (.h) and class implementation (.cpp).

Explanation / Answer

//This is Header File

#include <iostream>

#include <fstream>

#include <string.h>

using namespace std;

#define MAX 20

struct TestScores

{

int score1;

int score2;

int score3;

int score4;

int score5;

int score6;

int score7;

int score8;

int score9;

int score10;

};

class student

{

public:

const char student_name[30];

int student_ID;

struct TestScores *TScr;

float average;

student()

{

this->TScr = new TestScores;

}

student(char name[], int id, TestScores *ptr,float avg)

{

strcpy(this->student_name,name);

this->student_ID = id;

this->TScr = ptr;

this->average = avg;

}

void cal_average(void);

void enter_data(void);

void display(void);

};

//This is CPP File

#include "Student.h"

//member function definition, outside of the class

void student::enter_data(void)

{

cout << "Enter name: " ;

cin >> student_name;

cout << "Enter Student ID: ";

cin >> student_ID;

cout << "Enter the scores of Ten Tests: ";

cin >> TScr->score1;

cin >> TScr->score2;

cin >> TScr->score3;

cin >> TScr->score4;

cin >> TScr->score5;

cin >> TScr->score6;

cin >> TScr->score7;

cin >> TScr->score8;

cin >> TScr->score9;

cin >> TScr->score10;

}

void student::cal_average(void)

{

average = (float)(TScr->score1+TScr->score2+TScr->score3+TScr->score4+TScr->score5+TScr->score6+TScr->score7+TScr->score8+TScr->score9+TScr->score10)/10;

cout <<"In Average FUn ";

}

//member function definition, outside of the class

void display(student stdent_obj)

{

ifstream f("users.txt");

string buff;

cout <<"In Display FUn1 ";

while (getline(f,buff))

{

cout <<"In Display FUn2 ";

strcpy(stdent_obj.student_name, buff);

cout << buff;

stdent_obj.cal_average();

cout << "Student details: ";

cout << "Name: "<< stdent_obj.student_name << " Student ID: " << stdent_obj.student_ID << " Test Scores: " << stdent_obj.TScr->score1 << ", " << stdent_obj.TScr->score2 << ", " << stdent_obj.TScr->score3 << ", " << stdent_obj.TScr->score4 << ", " << stdent_obj.TScr->score5 << ", " << stdent_obj.TScr->score6 << ", " << stdent_obj.TScr->score7 << ", " << stdent_obj.TScr->score8 << ", " << stdent_obj.TScr->score9 << ", " << stdent_obj.TScr->score10<< " Average:" << stdent_obj.average;

cout << endl;

}

}

int main()

{

student stdent_obj[MAX]; //array of objects creation

FILE *fp;

fp=fopen("users.txt","rb+");

cout <<"Calling Display FUn ";

display(stdent_obj[0]);

return 0;

}