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
Your for loop conditions look wrong. Your starting condition is i = 0
, but your ending condition is i >= dom
. If dom is any integer greater than 0, then the for loop will never execute because i can't be both 0 and greater than or equal to a number that's greater than 0. I think you mean to say i <= dom
?