Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help with this homework, thanks !! NAME CSC 236- ArrayList and Generics c

ID: 3882881 • Letter: P

Question


please help with this homework, thanks !!

NAME CSC 236- ArrayList and Generics coding quz Write Java statements to odd the integers 1001, 1100, and 1110 to the resulting ArrayList from question 4 above. 5) 6) Write the Java statement to display the size of The resulting ArrayList from question 5 above. Write Java statements that use a for each loop to cycle through all the elements in on ArrayList of doubles named grades. 7) Write a Java method named average. The method should take an ArrayList of Integers as a parameter, compute the aw and return the average to the calling method 8)

Explanation / Answer

5)adding integrs to arrraylist.

//create the list with the ArrayList and add the elements.

6)To display the size of ArrayList

//list.size() ->used to find the arraylist size.

7)using for loop to cycle through the elements

8)find average:

float avg= average(list) // call method average with parameter Integer ArrayList list

//average function. compute the average and return the value.

total+=elem;

}

avg=(float)total / list.size();

return avg;

}

//any clarification please do comments