Question: Design a class called Student. Separate the declaration and methods definition file. The class should store the following student information: name: student's name, type is

Design a class called Student. Separate the declaration and methods definition file. The class
should store the following student information:
name: student's name, type is string
id: student ID
,
type is string
numTests: number of tests, type is int
scores: a pointer to an array of test scores, type is double
Define the following member functions:
Constructors:
Student
(
int
)
: Parameterized constructor with number of tests as the parameter.
Student
(
string
,
string, int
)
: Parameterized constructor with student name, student id
,
and number of tests as parameters.
Destructor
~Student
(
)
Mutator functions:
setName
(
string name
)
,
setId
(
string id
)
,
setScore
(
int testNum, double score
)
Accessor functions:
string getName
(
)
: get student name
string getId
(
)
: get student ID
double getScore
(
int n
)
: get score of test n
int getNumTests
(
)
: get number of tests
Use Lab05_2.cpp to test your class.
#include
#include "Student.h"
using namespace std;
int main()
{
Student s1("John Doe", "12345",3), s2(2);
s1.setScore(0,89);
s1.setScore(1,97);
s1.setScore(2,91);
s2.setName("Buzz");
s2.setId("02468");
s2.setScore(0,82);
s2.setScore(1,85);
//get students' first test score
cout << "Name: "<< s1.getName()<<" Score: "<< s1.getScore(0)<< endl;
cout << "Name: "<< s2.getName()<<" Score: "<< s2.getScore(0)<< endl;
//print students info
cout <<"
>>> Studdent 1<<<";
s1.printStudentInfo();
cout <<">>> Studdent 2<<<";
s2.printStudentInfo();
s1.setName("Joseph");
s1.setScore(1,100);
cout <<"
>>> Studdent 1<<<";
s1.printStudentInfo();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!