Question: Any one can help me fix this error? the program crashes when there is no date entered Your Program's Output Exception in thread main java.lang.ArrayIndexOutOfBoundsException:
Any one can help me fix this error?
the program crashes when there is no date entered
Your Program's Output
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at arrayOperations.main(arrayOperations.java:41) (Your program crashed here.)
?line 41: String fileName = args[0];
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Formatter; public class arrayOperations {
public double getTotal(double[] array){ double sum=0.0; for(int i=0; i public double getAverage(double[] array1){ double average=getTotal(array1)/array1.length; return average; } public double getHighest(double[] array2){ double max = array2[0]; for(int i=0; i } public double getLowest(double[] array2){ double min = array2[0]; for(int i=0; i } else{ continue; } } double arr[] = new double[n]; Scanner scan = new Scanner(file); for(int i=0; i } } }
Step by Step Solution
There are 3 Steps involved in it
The issue youre encountering is due to the program crashing when no commandline argument specifically a file name is provided leading to an ArrayIndex... View full answer
Get step-by-step solutions from verified subject matter experts
