Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifications on this piece of code

Status
Not open for further replies.

gio2888

Technical User
Oct 26, 2000
64
US
Can someone tell me if the specifications are correct?

public static double math1(int[] arr){
double sum = 0.0;
for (int i =0; i < arr.length; i++){
sum+ = arr;
}
return sum/ (double)arr.length;
}//end of math1()

Requires: integer array
Modifies: sum
Effects : return average
 
Look okay to me, although it could use some better formatting. This could also be due to the forum. Are you having problems or just looking for feedback?

I would change the last piece a bit.
Requires: integer array <-- should be int array
Modifies: sum <-- user doesn't need this information it is internal to the method.
Effects : return average <-- should specify the the average returned is of type double Wushutwist
 
Thanks for the clarifying this for me, I ve been having so much trouble in class figuring what to write in for specifications, but once again thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top