Answers for "java scanner string to int"

0

java scanner string to int

Scanner scanner = new Scanner(System.in);
    while (true) {
        String input = scanner.next();
            try {
                int a = Integer.parseInt(input);
                if (a == 0) {
                    break;
                }
                System.out.println(Integer.parseInt(input) * 10);
            } catch (NumberFormatException e) {
                System.out.println("Invalid user input: " + input);
            }
        }
Posted by: Guest on October-14-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language