When we talked about loops, we looked at several algorithms. They are very useful when working with ArrayLists
declare and initialize a variable to hold the sum for each element in the ArrayList add this value the sum
Record your participation in Piazza clicker question Lesson16 Q1
declare and initialize a variable to hold the sum for each element in the ArrayList (Use an enhanced for loop) get the area of the Circle add the area of this Circle to the sum
sumAreas
in CircleManager that returns the sum of all the areas. Use an enhanced for loop
Record your participation in Piazza clicker question Lesson16 Q2
averageArea
to return the average area or 0 if array list is empty.
initialize a variable max to the first element in the list
for each element
if this element is larger than the max
max = this element
Record your participation in Piazza clicker question Lesson16 Q3
largest
in CircleManager to get the largest Circle. If the ArrayList is empty, return null
set a boolean flag found to false initialize a variable first initialize a loop control variable index to 0 while there are more elements to look at and !found if this element is a match set first to this element set found to true else increment index
Record your participation in Piazza clicker question Lesson16 Q4
firstRadiusGreaterThan10
to get the first Circle with a radius greater than 10. If the ArrayList is empty or does not have an Circle with a radius greater than 10, return null
Record your participation in Piazza clicker question Lesson16 Q5
countRadiusGreaterThanOne
. If the ArrayList is empty, return 0. You will need to provide the method header this time.
Record your participation in Piazza clicker question Lesson16 Q6
radiusGreaterOrEqualTo10.
You need to write the method header