473,856 Members | 1,654 Online

# Arrays, Structures, Functions...... .helpppppp!!!

16 New Member
please everyone feel free to respond.

am posting an assignment that i was given in lab. i have been working on this for two days now. am not aking for the solution, I need serious guidance. i can write the structure but i get stuck when writing the functions. this the assignment below.

In this assignment, you will write a complete C++ program that simulates a small student database.
�� First define a structure (record) student to represents students with the following information:
Student ID number
Test1 … Test2 grades out of 100
�� Write a function Display that displays on the screen a student.
�� Write a function Read that reads in a student from the keyboard and return it.
�� Write a function Compute that takes a student and computes the letter grade based on his/her tests’ grades (100>= A >90; 90 >= B > 80; 80 >= C > 70; 70 >= D > 60; 60 > F ).
�� Then write the main function in order to test each of the above functions. For this purpose, you will declare an array of student called MiniClass of size 2.

QUESTION: when it says declare array of student of miniclass of size 2, why does it have to be a size 2? does that mean two different students or just two different grades?

ok this is what i have so far............ .

struct student{
int idnumber;
};

void display(student &)

I KNOW its pathetic but thats as far as i have gotten sucessfully. with the void funtion am not even sure what am suppose to after that step. i think Display and Compute ought to be void functions and Read a value function.
Dec 2 '06 #1
3 1505
Banfa
9,065 Recognized Expert Moderator Expert
QUESTION: when it says declare array of student of miniclass of size 2, why does it have to be a size 2? does that mean two different students or just two different grades?
2 because you prof said so just to limit the scope of the problem and it means 2 students. That is why it is called MiniClass because a class with only 2 students in it would be very small in deed.

ok this is what i have so far............ .

struct student{
int idnumber;
};
Your original post gives the impression that each student should have 2 test grades, not a single test grade as you have given them, these will be combined into a single course grade.

void display(student &)

I KNOW its pathetic but thats as far as i have gotten sucessfully. with the void funtion am not even sure what am suppose to after that step. i think Display and Compute ought to be void functions and Read a value function.

Expand|Select|Wrap|Line Numbers
1. void display(const student &student)
2. {
3.     // Code to display student data using printf or cout
4. }
5.
6. void compute(student &student)
7. {
9. }
10.
12. {
13.     // Code read student data from stdin using cin or fgets
14. }
15.
Dec 2 '06 #2
queenma7
16 New Member
2 because you prof said so just to limit the scope of the problem and it means 2 students. That is why it is called MiniClass because a class with only 2 students in it would be very small in deed.

Your original post gives the impression that each student should have 2 test grades, not a single test grade as you have given them, these will be combined into a single course grade.

Expand|Select|Wrap|Line Numbers
1. void display(const student &student)
2. {
3.     // Code to display student data using printf or cout
4. }
5.
6. void compute(student &student)
7. {
9. }
10.
12. {
13.     // Code read student data from stdin using cin or fgets
14. }
15.
thanks for the reply, but am still confused. i kind of knew this part. what i dont understand is how the array ties in to this. i understand the different parts of the program i just dont know how am suppose to make it work together as one.
Dec 2 '06 #3
Banfa
9,065 Recognized Expert Moderator Expert
thanks for the reply, but am still confused. i kind of knew this part. what i dont understand is how the array ties in to this. i understand the different parts of the program i just dont know how am suppose to make it work together as one.
Oh sorry so a simple main might look something like

Expand|Select|Wrap|Line Numbers
1. #define NUM_SUDENTS 2
2.
3. int main(int argc, char **argp)
4. {
5.     students MiniClass[NUM_SUDENTS];
6.     int ix;
7.
8.     for(ix=0; ix<NUM_SUDENTS; ix++)
9.     {
11.         compute(MiniClass[ix]);
12.     }
13.
14.     for(ix=0; ix<NUM_SUDENTS; ix++)
15.     {
16.         display(MiniClass[ix]);
17.     }
18. }
19.
Dec 2 '06 #4