cant figure out why requirement 2 isnt passing when program is working fine
package com.codegym.task.task14.task1420;
/*
GCD
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
String a = reader.readLine();
String b = reader.readLine();
if (!checkMethod(a, b)) {
throw new Exception();
}
int aa=Integer.parseInt(a);
int bb=Integer.parseInt(b);
if(!positive(aa,bb)){
throw new positiveNumberException("numbers cant be negative");
}
int c=GCD(aa,bb);
System.out.println(c);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
static boolean checkMethod(String a,String b){
try{
int aa=Integer.parseInt(a);
int bb=Integer.parseInt(b);
}
catch(Exception e){
return false;
}
return true;
}
static boolean positive(int a,int b){
if(a<0||b<0){
return false;
}
return true;
}
static int GCD(int aa,int bb){
int gcd=1;
for(int i=1;i<=aa || i<=bb;i++){
if(aa%i==0 && bb%i==0){
gcd=i;
}
}
return gcd;
}
}