0

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

3
Contributors
7
Replies
35
Views
2 Years
Discussion Span
Last Post by gusano79
-1

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

Votes + Comments
what about union struct??
-1

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.

Votes + Comments
struct Science { double exam[size]; }; struct Engineering { double quizzes[size]; }; union S_Eng_sci { Science S_exam; Engineering S_quizzes; }
-1
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;
};
Votes + Comments
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?
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.