Using Function

K

Keith

Hey Guys,

Can you help me understand this concept? I am trying to use function
qualityPoints here to return a value of 4 if an average is 90-100, 3 if it
is 80-90, 2 if its 70-80, 1 if its 60-70 and 0 if it drops below 60. I am
learning functions and trying to figure out what values should be between
the parentheses in the initializing phase, and also how it should be
written. I am on a mental block on this one. Here's what I have so far:

//Program returns the GPA based on student average

include <iostream>

include <cmath>

using std::cout;

using std::cin;

using std::end1;

int qualityPoints ( int, int, int, int, int, int )

int main() //function main begins program execution

{

int average; //student average

int GPA; //grade point average

cout << "Enter the student's average:";

cin >> average;

cout << "Grade Point Average Is:";

<< qualityPoints ( GPA ) << end1;

getch (); //indicates successful termination

}

//function qualityPoints definition

int qualityPoints (

Thanks for your help!
 
V

Victor Bazarov

Keith said:
Can you help me understand this concept? I am trying to use function
qualityPoints here to return a value of 4 if an average is 90-100, 3
if it is 80-90, 2 if its 70-80, 1 if its 60-70 and 0 if it drops
below 60. I am learning functions and trying to figure out what
values should be between the parentheses in the initializing phase,
and also how it should be written. I am on a mental block on this
one. Here's what I have so far:
//Program returns the GPA based on student average

[..nothing of substance..]

We don't do homeworks. However, here is a hint: given a value of the
average, compare it to 90, if it's greater or equal, return 4, if not,
compare it to 80, and so on.

V
 
K

Keith

Yeah, I'm not looking for someone to do it, just help me appreciate the
concept of functions, I can't get how they should be laid out.
 
V

Victor Bazarov

Keith said:
Yeah, I'm not looking for someone to do it, just help me appreciate
the concept of functions, I can't get how they should be laid out.

You'll find as many opinions about that as you'll hear voices. What
does the C++ book you're using to study, says?
 
J

Jaspreet

Keith said:
Hey Guys,
[snip requirements]

//Program returns the GPA based on student average

include <iostream>

include <cmath>

using std::cout;

using std::cin;

using std::end1;

int qualityPoints ( int, int, int, int, int, int )

Why do you have so many parameters here to be sent to qualityPoints ?
Right now you are provinding 6 ints. This is same as 6 input values.
But, as far as I understood your problem you just need to give as input
the average which you have already asked the user. Soo, to start with
you just need to give 1 input or only 1 int so your above line should
be:

int qualityPoints (int);

Now let us know how would you do this in real life if say your next
door neighbor tells you that he has got 76 as average. Another neighbor
tells you she got 85. You would simply have the table in front of you
and tell him/her their Gade Point Average.

Try it yourself and ask as many questions as you want but give it a
shot.
 

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,296
Messages
2,571,535
Members
48,282
Latest member
Xyprime

Latest Threads

Top