Data structures to be used
The program should use two distinct structure-types to store the students’ scores: the 1st type used for keeping scores of 4 quizzes while the 2nd type is used to keep the scores of 2 exams. A student can have either quizzes (if Engineering student) or exams (if Computer Science student) but not both, so you need to define a union structure to keep both structure types. The program must then use a single general structure called student that contains student’s first-name, last-name, college, grade (which to be calculated later) and the scores.
Finally, the data read from the file should be stored in a linked list of type student.

struct student{
    string first_name;
    string last_name;
    string college;
    char grade ;
    double *scores;
};
struct node1
{
    student data;
    node1 *next;
};

i do not know if its ok or not

can any one help me please ???

i cant start my code without this structur

Recommended Answers

All 7 Replies

please!!!!!!!!!!!!!!!!!!!!!!

change your scores from a double to a struct. You need two types, one for quizzes and one for exams.

commented: what about union struct?? +0

The program should use two distinct structure-types to store the students’ scores: the 1st type used for keeping scores of 4 quizzes while the 2nd type is used to keep the scores of 2 exams.

Where are the structures that keep scores? You're missing them, and they're necessary for everything else, so start there.

commented: struct Science { double exam[size]; }; struct Engineering { double quizzes[size]; }; union S_Eng_sci { Science S_exam; Engineering S_quizzes; } +0
struct Science 
{
    double exam[size];
};
struct Engineering  
{
    double quizzes[size];
};
union S_Eng_sci
{
    Science S_exam;
    Engineering S_quizzes;
};
struct student{
    string first_name;
    string last_name;
    string college;
    char grade ;
    S_Eng_sci scores;
    student *next;
};
commented: Please do not be rude to others who answered. Also, what is the naming convension for variable names? And array variable inside struct can be dynamic? -3

like that????

We're trying to help without doing the work for you. Those structs weren't in your original post; how am I supposed to know what you've done?

On to the code...

double exam[size];
double quizzes[size];

Assuming you're getting size from somewhere, should those really be the same? Forget arrays for a moment; you already know exactly how many scores each structure should have.

union S_Eng_sci
struct student

Sure, those work. Now, given student s, you can get "science" scores from s.scores.S_exam and "engineering" score from s.scores.S_quizzes.

All of the basic parts seem to be there; try putting them together in a simple program that just creates a few students and scores. See if you can get the data back out of your structures.

If that works, then...

struct node1

You can use that to construct a singly-linked list, but you'll still need to write code to manage the list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.