62592023-11-09 17:28:01RedStarDiana and NumbersjavaCompilation error
import java.util.Scanner;

public class DianaAndNumbers {

    static String maximum = "-1";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String number = sc.nextLine();

        printDividableNumber(number);

        System.out.println(maximum);
    }

    private static void printDividableNumber(String number) {
        if (checkIfDividable(number)) {
            maximum = returnBiggerNumber(number, maximum);
        }

        for (int i = 0; i < number.length(); i++) {
            if (!checkIfDividable(number.charAt(i) + "")) {
                String newNum = removeCharAt(number, i);
                if (!newNum.equals(""))
                    printDividableNumber(newNum);
            }
        }
    }

    public static String returnBiggerNumber(String num1, String num2) {
        if (num1.length() > num2.length())
            return num1;
        if (num2.length() > num1.length()) {
            return num2;
        }

        for (int i = 0; i < num1.length(); i++) {
            int n1 = Integer.parseInt(num1.charAt(i) + "");
            int n2 = Integer.parseInt(num2.charAt(i) + "");

            if (n1 > n2) {
                return num1;
            } else if (n2 > n1) {
                return num2;
            }
        }
        return num1;
    }

    public static String removeCharAt(String text, int index) {

        StringBuilder newString = new StringBuilder();

        for (int i = 0; i < text.length(); i++) {
            if (i != index) {
                newString.append(text.charAt(i));
            }
        }

        return newString.toString();
    }

    public static boolean checkIfDividable(String number) {
        int remainder = 0;

        //check if the first number is not a zero
        if (number.charAt(0) == '0') {
            return false;
        }

        for (int i = 0; i < number.length(); i++) {
            if (remainder != 0)
                remainder = Integer.parseInt(remainder + "" + number.charAt(i)) % 3;
            else
                remainder = Integer.parseInt("" + number.charAt(i)) % 3;


        }

        return remainder == 0;
    }

}
Compilation error
exit status 1