Вроде все исключения сделал, всё работает, если просто запустить, но не принимает.
package com.javarush.task.task14.task1420;
/*
НОД
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int y = get(bf.readLine());
int x = get(bf.readLine());
int nd = nod(x, y);
System.out.println(nd);
}
public static int nod(int x, int y) {
if (x < y) {
int x1 = x;
x = y;
y = x1;
}
int i = 2, nd = 1;
while (i <= y) {
if (y % i == 0 && x % i == 0) {
nd = i;
}
i++;
}
return nd;
}
public static int get(String s) throws OtrException {
int x;
boolean b = false;
try {
x = (int) Double.parseDouble(s);
} catch (Exception e) {
b = true;
}
if (b)
throw new OtrException("Введено не число");
else if (s.contains(".")) {
throw new OtrException("Число не целое");
} else if ((x = Integer.parseInt(s)) < 0) {
throw new OtrException("Число не положительное");
} else return x;
}
}
class OtrException extends Exception {
public OtrException(String message) {
super(message);
}
}