473,856 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
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 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............ .

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
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.

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 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.     {
  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
9512
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... function one(){ return $array; // yes, there is more to this function, and assume that "$array" is a real array }
4
10702
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 table via a stored procedure. Keep getting this error. Any suggestions? Code: 'ASP: if blnNewD then
3
8475
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. When debugging in VS 6 it says: "An exception of type 'Error in Microsoft VBScript: Incompatible types' was not handled". 'Main code '-----------------------------------------------------
6
2204
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 somebody enlighten me on how I would solve this? Here is what my prototype and my function look like: =====================================================
2
1977
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 to get bogged down. Do the arrays previously passed to the function stay memory resident? If not, what's causing it and what can I do to correct it? Thanks, Dave
7
1255
by: coinjo | last post by:
How to pass a full array into a function?
2
1571
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 the function or does it happen globally
6
2383
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
1361
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. The problem I ran into, was when the i tried to read the data in the structure I got garbage. Normally when I use arrays they retain the information that I enter once the function completes. I'm thinking that it has something to do with using the...
0
9916
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10782
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10384
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9531
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5761
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4174
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3201
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.