So here's the entirity of the code that matters
int dom = Integer.parseInt(Domin.getText());
double fraction = Integer.parseInt(Numer.getText())/Integer.parseInt(Domin.getText());
String currentlow = "";
System.out.println("TEST");
for (int i = 0; i >= dom;i++){ //ok the problem wasn't that it was > dom instead of >= dom
System.out.println("dummy"); //this doesn't print and it would print every time if it was running the for loop.
if((num % i == 0)&&(dom % i == 0)){ //this just = checks to see that there's no remainder (like 5/5)
System.out.println("true"); //this for some reason never triggers even though i'm testing with 5/25
if ((num/i)/(dom/i) == fraction){ //this is a dummy check to make sure it doesn't round improperly
currentlow = String.valueOf(num/i) + "/" + String.valueOf(i); //this sets the value but isn't the problem since the console never says "true"
System.out.println(currentlow); //nother dummy check
}
}
}
edit out the comments if you want, but basically the for-loop is supposed to cause it to divde by all the numbers less than the dominator, but it never even opens up the for loop (it doesn't print "dummy" or "true" ever, when it should print them 24 times in my testing) can't figure out why
dom/i
call, since it is integer division.i >= dom
— what is the text ofDomin.getText()
and therefore the value ofdom
? You are starting ati = 0
and checking ifi
is GREATER THAN OR EQUAL todom
so, unlessdom
is a negative number this will never loop.