help me

K

kickioly

Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.



Write a C++ program that calls the following functions:

a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

b) CalculateTotalMark that calculates, for each student, the total mark
earned (0 - 100).

c) FindGrade that finds the relevant character grade for each student.

d) CalculateAverage that calculates the Class average.

e) DisplayBelowAverage that displays students' name, address and
date of birth of with total mark below class average.

Notes:

1. The total number of students is not known in advance: You should
find a way to stop reading students' information!!

2. Store students' information in an array of struct.

3. Choose appropriate parameters (calling by value / by reference) to
all the functions needed.

4. Do not use global variables!!!
 
B

benben

Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.
[C++ homework spec snipped]

We understand you have C++ project undertaken but you forgot to tell us
what exactly your problem is.

Regards,
Ben
 
I

Ivan Vecerina

: Hi everyone, this is my first time here and i hope it will not be the
: last, i have a problem here solving this C++ problem,and i hope that
: someone here to solve it and i'll be happy if you do it for me.

Please read this NG's FAQ:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

Give it a try yourself first, then post portions of your code
and ask for specific advice or help.


Ivan
 
D

Daniel T.

Write a C++ program that calls the following functions:

a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

Let's start small. What do you think the input of the above function
should be? What should its output be? Answer the same questions for each
of the functions below as well.
 
K

kickioly

benben said:
Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.
[C++ homework spec snipped]

We understand you have C++ project undertaken but you forgot to tell us
what exactly your problem is.

I solved some exercises and i faced this problem and i dont know where
do i start with it, I must to discuss this problem in the class
tomorrow, I just hope to anyone solved it note that we have taken
arrays and structs.
 
S

Salt_Peter

Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.



Write a C++ program that calls the following functions:

a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

b) CalculateTotalMark that calculates, for each student, the total mark
earned (0 - 100).

c) FindGrade that finds the relevant character grade for each student.

d) CalculateAverage that calculates the Class average.

e) DisplayBelowAverage that displays students' name, address and
date of birth of with total mark below class average.

Notes:

1. The total number of students is not known in advance: You should
find a way to stop reading students' information!!

2. Store students' information in an array of struct.

3. Choose appropriate parameters (calling by value / by reference) to
all the functions needed.

4. Do not use global variables!!!

You can do it !!
start with a) and only a). How do you store a student? Forget the
marks.

If we do the homework for you:
1) you'll be twice as confused.
2) the teacher will know
3) you will have learned nothing
 
O

osmium

Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.



Write a C++ program that calls the following functions:

a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

Use simple names like Sally, John, and so on. You are not taking a typing
class. Date of birth is likely a struct within a struct. I would make
those four scores an array within an array - it will make computation of the
total easier later on. .
b) CalculateTotalMark that calculates, for each student, the total mark
earned (0 - 100).

c) FindGrade that finds the relevant character grade for each student.

The instructor may give you some guidelines here for the conversion,
otherwise make some thresholds up yourself.
d) CalculateAverage that calculates the Class average.

Note that an average is usually a decimal number, not an integer.
e) DisplayBelowAverage that displays students' name, address and
date of birth of with total mark below class average.

I don't know what that means.
Notes:

1. The total number of students is not known in advance: You should
find a way to stop reading students' information!!

Look up EOF. The user signals EOF with ctrl d (Unix) or ctrl z (Windows).
2. Store students' information in an array of struct.

The array should be owned by main since many of the functions will have to
share the same data. Guess at an initial size, and double your guess every
time the current guess is exceeded. An array of your own devising is not a
really good way to handle this problem, but there is absolutely nothing to
be gained by being a smart ass. At least in school.
3. Choose appropriate parameters (calling by value / by reference) to
all the functions needed.

4. Do not use global variables!!!

Start by defining a struct to contain the student data.
Compile *often*!
 
?

=?ISO-8859-1?Q?Martin_J=F8rgensen?=

Daniel said:
Let's start small. What do you think the input of the above function
should be? What should its output be? Answer the same questions for each
of the functions below as well.

Agreed. How about making a students class?

I'll also just contribute a bit:

class Students
{
private:
string name;
string address;
// dob - well, this is an interesting problem...
int mark1;
int mark2;
int mark3;
int mark4;

public:
// constructor etc..
// read_student( something ... )
// something that calculates average...
// etc... functions b/c/d/e/whatever
}

Don't know if there are better ways... I still have a lot to learn...

And ofcourse:

int main
{
// use of students class here...
}


Best regards
Martin Jørgensen
 
D

Daniel T.

Martin Jrgensen said:
Agreed. How about making a students class?

It's tough to say. The OP may not be allowed to use class constructs yet
(if the teacher hasn't covered the topic for example.)

That's one reason I tend not to present solutions to homework
assignments. It's highly likely that I will use constructs that the
student doesn't yet know about.
I'll also just contribute a bit:

class Students
{
private:
string name;
string address;
// dob - well, this is an interesting problem...
int mark1;
int mark2;
int mark3;
int mark4;

public:
// constructor etc..
// read_student( something ... )
// something that calculates average...
// etc... functions b/c/d/e/whatever
}

Don't know if there are better ways... I still have a lot to learn...

Often, homework assignments are over-specified because the teacher is
trying to stress a particular solution. In this case the student was
specifically asked to produce a particular set of functions. The
question is, can they be member-functions?
 
J

Jim Langston

Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.



Write a C++ program that calls the following functions:

Note: "functions" Means you'll need to write functions.
a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

Your teacher didn't specify where it was to read them from, the keyboard or
a file. For simplicity I would read from they keyboard. Somehow you need
to get the data from this function to the main program. Best way would be
to return something, most likely a structure. So, design a structure with
the information ( name, address, etc...) and return it.

StudentInfo READSTUDENTS()
{
// write code here to read from the keyboard into the StudentInfo structure
you designed
}
b) CalculateTotalMark that calculates, for each student, the total mark
earned (0 - 100).

Again, a function. Since you already have a structure with the info, just
pass that in and return the total mark.

int CalculateTotalMark( StudentInfo )
{
// calculate total mark and return it
}
c) FindGrade that finds the relevant character grade for each student.

You could pass in the total mark you calculated in the previous function,
and return a character grade, I would return a std::string

std::string FindGrade( int TotalMark )
{
// calculate grade string from total mark and return it
}
d) CalculateAverage that calculates the Class average

Okay, now you have to pass in all the class's grades. So we'll want to hold
those StudentInfo structures in some type of array, I would use a
std::vector. Return the average. Note, teacher wants you to use an array
of struct instead.

int CalculateAverage( StudentInfo[] Students, int NumOfStudents )
{
// iterate through the StudentInfo and calculate the class average and
return it
}
e) DisplayBelowAverage that displays students' name, address and
date of birth of with total mark below class average.

Hmm.. It looks like we have a need to store this info somewhere, so you
should add the fields to the StudentInfo, their grade, average, etc... Keep
that in mind when designing the above functions, or modify them now to do
that
Notes:

1. The total number of students is not known in advance: You should
find a way to stop reading students' information!!

Since we are using std::cin entering a name of X would work. Or some other
method you decide on.
2. Store students' information in an array of struct.

Array of struct? How can you store them in an array of struct when you
don't know how many are to be stored? This is (IMO) a wrong way to approach
this, but it's your instructor. Just make sure you have a large enough
array. I would go with 1024 or 2048 or something, and make sure you don't
try to load more in.
3. Choose appropriate parameters (calling by value / by reference) to
all the functions needed.
Right

4. Do not use global variables!!!

Right.

Go over everything and then start with step 1.

This is more help than I normally give for homework, and is all I'll give.
 
K

kickioly

Jim said:
Hi everyone, this is my first time here and i hope it will not be the
last, i have a problem here solving this C++ problem,and i hope that
someone here to solve it and i'll be happy if you do it for me.



Write a C++ program that calls the following functions:

Note: "functions" Means you'll need to write functions.
a) READSTUDENTS that reads students' Name, Address, Date of Birth,
and 4 marks: First test mark (0 - 10), Midterm exam mark (0- 20), Lab
mark (0-30) and Final exam mark (0-40).

Your teacher didn't specify where it was to read them from, the keyboard or
a file. For simplicity I would read from they keyboard. Somehow you need
to get the data from this function to the main program. Best way would be
to return something, most likely a structure. So, design a structure with
the information ( name, address, etc...) and return it.

StudentInfo READSTUDENTS()
{
// write code here to read from the keyboard into the StudentInfo structure
you designed
}
b) CalculateTotalMark that calculates, for each student, the total mark
earned (0 - 100).

Again, a function. Since you already have a structure with the info, just
pass that in and return the total mark.

int CalculateTotalMark( StudentInfo )
{
// calculate total mark and return it
}
c) FindGrade that finds the relevant character grade for each student.

You could pass in the total mark you calculated in the previous function,
and return a character grade, I would return a std::string

std::string FindGrade( int TotalMark )
{
// calculate grade string from total mark and return it
}
d) CalculateAverage that calculates the Class average

Okay, now you have to pass in all the class's grades. So we'll want to hold
those StudentInfo structures in some type of array, I would use a
std::vector. Return the average. Note, teacher wants you to use an array
of struct instead.

int CalculateAverage( StudentInfo[] Students, int NumOfStudents )
{
// iterate through the StudentInfo and calculate the class average and
return it
}
e) DisplayBelowAverage that displays students' name, address and
date of birth of with total mark below class average.

Hmm.. It looks like we have a need to store this info somewhere, so you
should add the fields to the StudentInfo, their grade, average, etc... Keep
that in mind when designing the above functions, or modify them now to do
that
Notes:

1. The total number of students is not known in advance: You should
find a way to stop reading students' information!!

Since we are using std::cin entering a name of X would work. Or some other
method you decide on.
2. Store students' information in an array of struct.

Array of struct? How can you store them in an array of struct when you
don't know how many are to be stored? This is (IMO) a wrong way to approach
this, but it's your instructor. Just make sure you have a large enough
array. I would go with 1024 or 2048 or something, and make sure you don't
try to load more in.
3. Choose appropriate parameters (calling by value / by reference) to
all the functions needed.
Right

4. Do not use global variables!!!

Right.

Go over everything and then start with step 1.

This is more help than I normally give for homework, and is all I'll give.

My Hat Off to :
benben, Ivan Vecerina, Daniel T, Salt_Peter, osmium, Martin Jørgensen,
Jim Langston
Thank you

I can see alot of things that i didnt notes it befor, and its being
clear for me..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top