# Problem with Functions

• (2 Pages)
• 1
• 2

## 25 Replies - 1663 Views - Last Post: 17 September 2011 - 03:48 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=247316&amp;s=5af1f3b1eb36a925a6571788ed16331c&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 15 September 2011 - 02:52 PM

This is my code so far..i know there are many mistakes. But check and tell me. Thanks.
```#include <iostream>
using namespace std;

void getJudgeData(double &judgescore)
{
cout << "Enter the score of the performer." << endl;
cin >> judgescore;

while (judgescore < 0 || judgescore > 10)
cout << "Please enter a value between 0 and 10." << endl;
cin >> judgescore;
}

double calcScore(double score1, double score2, double score3, double score4, double score5)
{
double total = score1+score2+score3+score4+score5;

findLowest;
findHighest;

}

int findLowest(double value1,double value2,double value3,double value4,double value5)
{
double lowest = -1;

if(lowest > value1)
lowest = value1;
else if (lowest > value2)
lowest = value2;
else if (lowest > value3)
lowest = value3;
else if (lowest > value4)
lowest = value4;
else if (lowest > value5)
lowest = value5;

return lowest;
}

int findHighest(double value1,double value2,double value3,double value4,double value5)
{
double highest = 11;

if(highest < value1)
highest = value1;
else if (highest < value2)
highest = value2;
else if (highest < value3)
highest = value3;
else if (highest < value4)
highest = value4;
else if (highest < value5)
highest = value5;

return highest;
}

int main()
{
double value1,value2,value3,value4,value5;

getJudgeData(value1);
getJudgeData(value2);
getJudgeData(value3);
getJudgeData(value4);
getJudgeData(value5);

calcScore;

```

This post has been edited by JackOfAllTrades: 15 September 2011 - 03:59 PM
Reason for edit:: Removed unnecessary quote

• Saucy!

Reputation: 6237
• Posts: 24,002
• Joined: 23-August 08

## Re: Problem with Functions

Posted 15 September 2011 - 04:00 PM

We're not your personal compilers. Does it compile? Does it run? What is the problem?

EDIT:

Quote

i really don't understand the C++ language that is the problem.

This assignment gets posted every semester. I'm guessing DeVry maybe is your school? Fact is, it could just be that C++ programming is not for you. That, or maybe you're just not trying hard enough.

### #18 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 15 September 2011 - 04:42 PM

JackOfAllTrades, on 15 September 2011 - 04:00 PM, said:

We're not your personal compilers. Does it compile? Does it run? What is the problem?

EDIT:

Quote

i really don't understand the C++ language that is the problem.

This assignment gets posted every semester. I'm guessing DeVry maybe is your school? Fact is, it could just be that C++ programming is not for you. That, or maybe you're just not trying hard enough.

I will find a way..if it is that hard to help.

### #19 Mina-kun

Reputation: 20
• Posts: 43
• Joined: 13-September 11

## Re: Problem with Functions

Posted 15 September 2011 - 09:46 PM

Looking over your code, I'm noticing several issues right away.

For starters, you aren't actually passing any variables to findHighest or findLowest, nor are you actually calling them. Any time you're invoking a function, you need to include the open/close parenthesis and a list of arguments (if applicable) in the function call.

Second, you flipped the positions findHighest/findLowest initial values. For the highest, you need to set an invalid low value (such as -1) and check if any of the values is higher than the running value. Similarly, you need to set an invalid high value when finding the lowest value.

When you call calcScore, you need to pass the score variables.

Within calcScore, you need to output the average score after it is calculated.

And finally, you need to ensure that you actually handle the values returned by findLowest and findHighest.

Beyond the help we are trying to give you, I recommend speaking with your instructor or possibly getting a mentor. I understand from some of the students that I worked with during an introduction to programming course (which was funny, given my experience... I learned to test out of courses I don't need after that one. ;p) that understanding the logic behind it can be difficult, but the important thing is the effort put into learning.

### #20 baavgai

• Dreaming Coder

Reputation: 6608
• Posts: 13,948
• Joined: 16-October 07

## Re: Problem with Functions

Posted 16 September 2011 - 06:06 AM

qwerty159, on 15 September 2011 - 07:42 PM, said:

I will find a way..if it is that hard to help.

Wow.

It depends on how you define help. We try to help people learn how to program. Just giving someone the answer teaches them nothing. Having them figure out the answer on their own, with a push in the right direction, is far more helpful for some honestly trying learn.

If you're just trying to finish the assignment with minimal effort and have no interest in actually learning anything, then no, we're not going to be that helpful.

If by "find a way" you mean trying to get someone else to do it, or apparently PMing people, then you are dooming yourself to continued failure. Good luck with that.

### #21 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 17 September 2011 - 02:48 PM

baavgai, on 16 September 2011 - 06:06 AM, said:

qwerty159, on 15 September 2011 - 07:42 PM, said:

I will find a way..if it is that hard to help.

Wow.

It depends on how you define help. We try to help people learn how to program. Just giving someone the answer teaches them nothing. Having them figure out the answer on their own, with a push in the right direction, is far more helpful for some honestly trying learn.

If you're just trying to finish the assignment with minimal effort and have no interest in actually learning anything, then no, we're not going to be that helpful.

If by "find a way" you mean trying to get someone else to do it, or apparently PMing people, then you are dooming yourself to continued failure. Good luck with that.

Listen ...I didn't mean to get someone else to do my code by saying "find a way" and as far minimal effort goes...you are wrong about that. I finished my code. And it was working perfectly. I was up till 1:45 am. Not to mention I am an "A" student. Whenever I ask for help on this website I don't expect any of u to just give me the code. But when I put normal comments some people just reply me by writing negative comments and gives me a negative rep for doing nothing. Why ? I don't have right to say anything ? I understand you guys are experts but that doesn't mean that people like me are dumb. I might get a negative rep for writing this but I don't care. I always like this website because you guys are faster than the others in replying to my question. You should also understand that when a person is under pressure some comments just comes out. I am not typing bad words. I am just writing what I feel.

For example when I wrote

"Anyone interested in helping ? I never get help..."

My rep went down by 2. What is so bad about that comment. I was under pressure. That is why I wrote that.

I hope you understand..I am not a bad person I am a pretty calm person..but I hate people who thinks they are superior that the others. I hope I will still get help from this website. You guys have a good team. Cheers !!

### #22 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 17 September 2011 - 02:55 PM

THANKS A LOT !! FOR YOU HELP..I did it. I made it work

This post has been edited by JackOfAllTrades: 18 September 2011 - 06:45 AM
Reason for edit:: Removed unnecessary quote

### #23 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11798
• Posts: 44,322
• Joined: 27-December 08

## Re: Problem with Functions

Posted 17 September 2011 - 03:07 PM

Quote

"Anyone interested in helping ? I never get help..."

My rep went down by 2. What is so bad about that comment. I was under pressure. That is why I wrote that.

What you have to keep in mind is that everyone here helps out on a volunteer basis. Nobody gets paid for helping. So our members make a good faith effort to help you, then you reply with that you never get any help. Lashing out at members who are honestly trying to teach you and help you sounds very unappreciative and ungrateful.

Quote

You should also understand that when a person is under pressure some comments just comes out.

And that justifies diminishing the efforts of members who are going out of their way to teach you and help you? Some of these replies you got were truly in-depth, helpful, and took the posters a good 10+ minutes to crank out. And in my opinion, lashing out at members volunteering to help you and expecting you to work at it some is like lashing out at Habitat for Humanity for involving you in the construction of a house that you get for free.

Nobody here has an attitude of superiority. On the same token, we expect posters to put in a good faith effort when offered advice.

### #24 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 17 September 2011 - 03:40 PM

ok ..why don't you just look at the reply from JackofAllTrades when I wrote "i really don't understand the C++ language that is the problem." I mean comeon i am writing my own problem why does it have to bother anyone else ? I was just telling Mina-kun that the words in the C++ language or the functions is complicated for me to understand. I am not telling Mina-kun that his explanation or anything is bad. I am actually thankful to him because he is the one who helped me a lot.

This post has been edited by JackOfAllTrades: 18 September 2011 - 06:46 AM

### #25 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11798
• Posts: 44,322
• Joined: 27-December 08

## Re: Problem with Functions

Posted 17 September 2011 - 03:42 PM

JackOfAllTrades makes a valid point though- you should be the one compiling your code and telling us what problems or errors you are encountering. Not the other way around.

You:

Quote

This is my code so far..i know there are many mistakes. But check and tell me. Thanks.
<Posted Code>

Jack:

Quote

We're not your personal compilers. Does it compile? Does it run? What is the problem?

EDIT:

Quote

I wrote "i really don't understand the C++ language that is the problem."

And he gave you resources so you could learn it.

### #26 qwerty159

Reputation: -8
• Posts: 43
• Joined: 22-November 10

## Re: Problem with Functions

Posted 17 September 2011 - 03:48 PM

Don't want to argue. PEACE

This post has been edited by JackOfAllTrades: 18 September 2011 - 06:46 AM
Reason for edit:: Removed unnecessary quote