Untitled page

package work1;

public class test1 extends Exception{
	public test1(String message) {
		super(message);
	}
}

###

package work1;

public class yue {
	public static int findyue(int a, int b) throws test1 {
		if(a < 0 || b < 0) {
			throw new test1("输入不能为负数!");
		}
		while(b != 0) {
			int r = b;
			b = a % b;
			a = r;
		}
		return a;
	}
}

###

package work1;

import java.util.Scanner;

public class main1 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.print("请输入第一个整数:");
		int num1 = scanner.nextInt();
		System.out.print("请输入第二个整数:");
		int num2 = scanner.nextInt();
		
		try {
			int sum = yue.findyue(num1, num2);
			System.out.print("最大公约数:" + sum);
		}catch(test1 e) {
			System.out.println(e.getMessage());
		}
		
		scanner.close();
	}
}