How can I do a default constructor that will ask for a name to be entered from the keyboard and stores it. It also initializes a counter that keeps track of the number of scores in the array and is maintained when you add, remove, or clear.
You are to define a default constructor that will ask for a student name to be entered from the keyboard and stores it. It also initializes a counter that keeps track of the number of scores in the array and is maintained when you add, remove, or clear.
You have to define a null destructor.
·
The maximum number of test scores is 5 and isstored in the class data as a static constant.
Accept a student’s name (string)and maintains an array of test scores (float). If there is room you can adda score at the first available position. That is the position immediatelyfollowing the last added score. If the array is empty, you add at the firstposition. If the array is full, then you cannot add and must indicate that. Ifthere are scores in the array, you can remove the last score; scores in themiddle or front may not be removed. If the array is empty then you cannotremove and must indicate that. You can also clear the array of all thescores, but before you do that you must print the name and contents of thearray backward.
---------------------------------------------------------------------------------------------------------
The part that is throwing me off more is the default constructor part that prompts the users.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
class Student
{
private:
const int static num_scores;
string name;
float tests[5];
public:
Student()
{
name = "";
cout << "Please enter the student name: ";
cin >> name;
}
bool add(float);
bool remove();
void clear();
};
|