Задачу решил. Но вопрос про вывод с клавиатуры. Есть ли другие варианты, более компактные, чем у меня? BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String a1 = in.readLine(); String b1 = in.readLine(); String c1 = in.readLine(); int a = Integer.parseInt(a1); int b = Integer.parseInt(b1); int c = Integer.parseInt(c1);