Spot up to 10 errors in Java and FIX them public static void
Spot up to 10 errors in Java and FIX them!
public static void main (String [] args) {int [] spaceshipDiameters = new {20, 85, 34, 62, 45}; System out.println(\"The average spaceship\'s area is\" + getAverageSpaceshipArea(spaceshipDiameters []));} public double getAverageSpaceshipArea (int [] s) {for (int i = 0: iSolution
Hi,
I have fixed the issues and it is working fine now. Highlighted the code changes below.
Test.java
public class Test {
public static void main(String[] args) {
int[] spaceshipDiameters = new int[]{20,85,34,62,45};
System.out.println(\"The average spaceship area is \"+getAverageSpacesshipArea(spaceshipDiameters));
}
public static double getAverageSpacesshipArea(int[] s){
double total = 0;
for(int i=0; i<s.length; i++){
double currentArea = Math.PI * s[i] * s[i];
total+=currentArea;
}
return total;
}
}
Output:
The average spaceship area is 46024.332375090475
![Spot up to 10 errors in Java and FIX them! public static void main (String [] args) {int [] spaceshipDiameters = new {20, 85, 34, 62, 45}; System out.println(\ Spot up to 10 errors in Java and FIX them! public static void main (String [] args) {int [] spaceshipDiameters = new {20, 85, 34, 62, 45}; System out.println(\](/WebImages/42/spot-up-to-10-errors-in-java-and-fix-them-public-static-void-1130040-1761603474-0.webp)