I seem to be having a problem with my code which is to look for the repeating sequence of digits. I have converted(?) double to string because I get the error unreachable statement. (which I guess helps to looking for the reason why I get the error I have now?).
Whenever I run it, it goes fine until I finish entering N and D.
It'll say "Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 3"
Here is my code below:
import java.util.*; 
public class RepeatingSequence{
public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    System.out.print("Enter N,D: ");
    int numerator = in.nextInt();
    int denominator = in.nextInt();
    double quotient = numerator / denominator;
    String number = "" + quotient;
    char n = number.charAt(0);
    int j = 1;
    int z = 0;
    String output = "";
    char[] index = number.toCharArray();
    for ( int i = 2; number.charAt(j) != number.charAt(i); i++ ){
        index[z] = number.charAt(z);
        index[j] = number.charAt(j);
        index[i] = number.charAt(i);
        output = output + index[i];
        if ( index[i] != index[z] ){
        System.out.print(index[z] + ".(" + index[j] + output + ")");
        }
    }   
}
}
 
     
     
    