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

#include <iostream> #include <string> #include <iomanip> using namespace std; //

ID: 3535797 • Letter: #

Question

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//Class declaration
class Student
{
private:
string name;
int id;
int *test;
int num;
void makeArray();
public:
Student();
Student(int n);
Student(string nm, int i, int n);
void setName(string nm);
void setID(int i);
void setScore(int i, int s);
string getName() const;
int getID() const;
void showScore();
void display();
~Student();
};

void Student::makeArray()
{
int size = Student::num;
int *studentArray;
studentArray = new int[num];
Student::test == studentArray;

test = 0;
}

//Student 1 function
Student::Student()
{
setName("NONE");
setID(10);
Student::num = 3;


}

//Student 2 function
Student::Student(int n)
{
setName("None");
setID(10);
if(n > 0){
Student::num = n;
}else{
Student::num = 3;
}
makeArray();
}

//Third student function, takes in 3 parameters
Student::Student(string nm, int i, int n)
{
setName(nm);
setID(i);
if(n > 0){
Student::num = n;
}else{
Student::num = 3;
}
makeArray();
}

//sets name to nm
void Student::setName(string nm)
{
Student::name = nm;
}

void Student::setID(int i)
{
if(i >= 10 && i <= 99){
Student::id = i;
}else{
Student::id = 10;
cout << "Invalid. Can not set id to " << i << " for " << getName() << endl;
}
}

void Student::setScore(int i, int s)
{
if(i < Student::num){
if(s >= 0 && s <= 100){
test[i] == s;
}else{
cout << "Invalid. Can not set test " << i << " to " << s << " for " << getName() << endl;
}
}else{
cout << "Invalid. Can not set test " << i << " to " << s << " for " << getName() << endl;
}
}

//returns the name
string Student::getName() const
{
return Student::name;
}

//returns the id
int Student::getID() const
{
return Student::id;
}

//displays the test number and the score
void Student::showScore()
{
for(int count = 0; count < Student::num; count++)
{
cout << "Test " << count << "had a score of " << test[count] << endl;
}
}

//get and display the student's information
void Student::display()
{
cout << "The Name: " << getName();
cout << "The ID: " << getID();
showScore();
cout << endl;
cout << endl;
}

Student::~Student()
{
free(test);
}
int main()
{
//sets up the 3 students
Student a;
Student b(4);
Student c("Joe", 40, 5);

cout << "Calling the set functions";
//for student a
a.setName("Tom");
a.setID(200);
a.setID(20);
a.setScore(0, 75);
a.setScore(1, 85);
a.setScore(2, 95);

//for student b
b.setName("John");
b.setID(30);
b.setScore(0, 70);
b.setScore(1, 80);
b.setScore(2, 90);
b.setScore(3, 100);

//for student c
c.setScore(0, 90);
c.setScore(1, 91);
c.setScore(2, 92);
c.setScore(3, 93);
c.setScore(4, 94);
c.setScore(5, 95);
c.setScore(4, 105);
c.setScore(5, 105);

//the display function
cout<< "Calling the display function";
a.display();
b.display();
c.display();


system("pause");
return 0;
}

Explanation / Answer

What is the error YOu are facing?? If you tell me i can make it run foryou.. Thank You :)