Help with functional decomposition

Pages: 12
Part 3.
1) Then add a prototype (before the main function) for a function called
calcAverage() with the following prototype.
double calcAverage(int score1,int score2,int score3);
2) In your main function, add a declaration for a variable called average of
type double.
3) Add statement in main(), after the work done in part 2 above, to call the
calcAverage() passing the three scores and then return the average. It will
be something like this:
average = calcAverage(score1,score2,score3);3
4) Add definition for your calcAverage() function by taking in the three values
passed and then calculate and return the value for average.
5) After the statement done in step 3 of this task (above) add a statement to
print the value for average returned from the calcAverage() function.
6) Run your program and enter three different scores and check that the average
is calculated (and displayed) correctly.
Do continue if this process is not working correctly.
7) Add documentation for your function; what it does, preconditions and
postconditions.

In your code, it says:

void printInfo(); //function prototype
int setScore();
double getAverage(int score1,int score2,int score3);

What happened to calcAverage? Hope its not annoying you. I am just trying to understand.
I changed all setScore to getScore because that's what it says but if I changed getAverage to calcAverage, it wont work.
Its fine,
1)its ok you can re-name functions and the prototype is there.
2)there are a variable of type double called average
3)there is this statement.
4)there is this definition; Read the comments its important
5)You can omit this step cuz after all will be deleted;
1
2
3
4
double average;
average=getAverage(score1,score2,score3); //or calcAverage
cout<<"Average : "<<average<<endl;
//thats all 

6) Just run your program
7)Documentation

I change calcAverage by getAverage seems better to my point of view but anyway you can re-name it.

Did you read my private message?
Last edited on
I've renamed both getAverage to calcAverage but when doing so, I get an error saying,"[Error] Id returned 1 exit status"
change
1-prototype
2.-where are called -in main-
3.-in the function definition
I don't understand. I'm so sorry. This is so frustrating.
have Skype?
Why does it work if it says getAverage but not when it says calcAverage? I am only changing the variable names
Nope. Why no matter what variable name I change it to, it won't work unless it is the variable name you choose?
In the lines 11,29,55 -of my code
change getAverage by clacAverage or whatever you want!
I did. I changed your getAverage to calcAverage but it doesn't work. It will only work if it says getAverage
in line 11?
line 29?
and line 55?
Topic archived. No new replies allowed.
Pages: 12