I have written a java program that does exactly what it's supposed to, however, the answer needs to be rounded to 5 decimal places.
I've googled it a ton, but every post I see has a double input. This is a sumArea answer that needs to be rounded.
public class COSC_HW13
{
// Main method
public static void main(String[] args)
{
// Create an array of four objects
GeometricObject[] array = {new Circle(5), new Circle(8),
new Rectangle(3, 4), new Rectangle(4, 2)};
// Display results
System.out.println("Total area of elements in array: "
+ sumArea(array));
}
// Returns the sum of the areas of
//all the geometric objects in an array
public static double sumArea(GeometricObject[] a)
{
double sum = 0;
for (int i = 0; i < a.length; i++)
{
sum += a[i].getArea();
}
return sum;
}
}