Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Discuss the costs associated with maintaining inventories.

Answered: 1 week ago