By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

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

P: 16
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
Letter grade
�� 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.............

enum gradetype {A, B,C,D,F};

struct student{
int idnumber;
int testgrade;
gradetype coursegrade;
};

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.
pleaseEEEEE SOMEONE HELP!!!! Thanks so much in advance.
Dec 2 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
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.............

enum gradetype {A, B,C,D,F};

struct student{
int idnumber;
int testgrade;
gradetype coursegrade;
};
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.
pleaseEEEEE SOMEONE HELP!!!! Thanks so much in advance.
This looks about right

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. {
  8.     // Code to calculate course grade from test grades
  9. }
  10.  
  11. student read(void)
  12. {
  13.     // Code read student data from stdin using cin or fgets
  14. }
  15.  
Dec 2 '06 #2

P: 16
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.

This looks about right

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. {
  8.     // Code to calculate course grade from test grades
  9. }
  10.  
  11. student read(void)
  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
Expert Mod 5K+
P: 8,916
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.     {
  10.         MiniClass[ix] = read();
  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

Post your reply

Sign in to post your reply or Sign up for a free account.