473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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
3 1475
Banfa
9,065 Expert Mod 8TB
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
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
9,065 Expert Mod 8TB
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

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

Similar topics

1
by: Eric Kincl | last post by:
OK, another quickie, How do I pass an array to a function? This is what I have, and the second function doesn't seem to be getting the array somehow. I'm sure it's in the function declaration......
4
by: Laura | last post by:
Help. Below is my code. Getting Type mismatch error on the noted line. I'm trying to send an array (aryNewD) with 4 columns and x rows to a function to save all the array info into a SQL Server...
3
by: Henry | last post by:
Hi, I need to pass an array to a function, change it a little and return it to the main code. When i try it the webpage is displayed up until the function call. Nothing after that is displayed....
6
by: fivelitermustang | last post by:
I have two matrices allocated dynamically in both directions: matrix x and matrix v. I want to pass these matrices into a function by reference. What I have written down isn't working... can...
2
by: dave.harper | last post by:
I'm relatively new to C++, but have a question regarding functions and arrays. I'm passing a relatively large array to a function several thousand times during the course of a loop, and it seems...
7
by: coinjo | last post by:
How to pass a full array into a function?
2
by: viggu | last post by:
how to pass arrays into the function and what is the use of functions.what do you mean by a modification of the array values in the function and does the modification of the values occur only inside...
6
by: rainy6144 | last post by:
Does the following code have defined behavior? double *new_array(unsigned n) { double *p = malloc(n * sizeof(double)); unsigned i; for (i = 0; i < n; i++) p = 0.0; return p; }
0
by: Art Cummings | last post by:
Good morning all. I just finished an assignment using structures. In this assignment I used an array of structures. What I would have liked was to use an array of structures with a function. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.