Hi im working on this program im getting a runtime error that says this ArrayIndexoutofbounds exception 0.
heres my code
import java.util.Scanner;
public class MillerCalculateTime
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter miles: ");
double miles = sc.nextDouble();
System.out.print("Enter Miles per hour: ");
double mph = sc.nextDouble();
System.out.println("\n\nEstimated travel time");
double initial = miles / mph;
String splitter = Double.toString(initial);
String[] splittersegment = splitter.split(".");
System.out.println("Hours: " + splittersegment[0]);
String min = "." + splittersegment[1];
double minutes = Double.parseDouble(min);
double minute = minutes * 60;
int minu = (int) minute;
System.out.println("Minutes: " +minu);
}
}
the code that is being highlighted for the error is this
System.out.println("Hours: " + splittersegment[0]);
any insight would be greatly appreciated