Static Stack program?

hey guys, i'm new here, and I really need help on an assignment. I'm completely lost on static stacks and linked lists, and this is what he wants us to do. can you help me with the code?

Static Stack

Create an array of student records (at least 15) and put all the related student records information in an array: Student ID(Axxxxxxxx), Name, Address and average of test scores and a Pointer for Test Scores (at least 10 scores).

-Display the student records in the array (do not display pointers).

-Push all student records from the array to a static stack

-Pop 5 student records from the stack and display the popped records.

-Display the remaining student records in the static stack.

(Loops are needed, Stack Class definition must be used, using template and container is optional.)

he also probably doesn't care if the records are from an existing input file or manually created, as he wasn't clear about that. thanks so much!
Nobody is going to do your homework for you. You need to try it yourself and ask for help with things that don't work properly.
To attack a problem like this, read the assignment and make notes of the classes that you will need. When you're done, go back through it again to see if you've missed anything. Once you have everything you need, convert your notes to header files. Then implement the code.

For example
Create an array of student records (at least 15)

class Student
constexpr int NumStudents = 20;
Student students[NumStudents];
Question: can you use a vector<> instead of an array?

put all the related student records information in an array

// populate the array. Return the number of students inserted?
int populateStudents(students);

Student ID(Axxxxxxxx), Name, Address and average of test scores and a Pointer for Test Scores (at least 10 scores).

So class Student has
string ID;
string Name;
string Address;
double averageScore;
int *scores;

Question: how will you store the number of scores? Can you use a vector instead of a pointer?
Question: if you have to store scores with a pointer then you need to store the number of scores, Also you need a copy constructor and assignment operator to copy the values.

Display the student records in the array (do not display pointers).

operator << (ostream &, const Student &) to print one student. Then a simple
loop to print the array
Push all student records from the array to a static stack

Need a static stack:
class Stack
Student values[20];
size_t top; // index of top of stack
Student &pop;
bool push(const Student &);
private:
Student values[20];
Pop 5 student records from the stack and display the popped records.

Do it in main()
Pop 5 student records from the stack and display the popped records.

Do it in main()
Display the remaining student records in the static stack.

Do it in main().

That's the first pass. In the second pass you should be able to make notes of what goes into main(). You might even write a main() function with nothing but comments at this point and fill in the code later.

Topic archived. No new replies allowed.