Write a method definition for a method named "average" that accepts two integer parameters and returns an integer value. The return value for the method should be the average of the two parameter values (and remaninder of the division should be ignored)
I got this..
public int average(int y, int z){
? ? ? ? ? ?int average;
? ? ? ? ? ?answer = y+z;
? ? ? ? ? ?
? ? ? ? ? ? ? return answer;
}
I know I'm missing the division just trying to figure it out.
Question
lotus22
Write a method definition for a method named "average" that accepts two integer parameters and returns an integer value. The return value for the method should be the average of the two parameter values (and remaninder of the division should be ignored)
I got this..
public int average(int y, int z){ ? ? ? ? ? ?int average; ? ? ? ? ? ?answer = y+z; ? ? ? ? ? ? ? ? ? ? ? ? ? return answer; }I know I'm missing the division just trying to figure it out.
Edited by lotus22Link to comment
Share on other sites
2 answers to this question
Recommended Posts