hi, i have a school project that asks for 2 classes to print factors of a number using 2 methods nextFactor and hasMoreFactors it does not specify if they are supposed to be void or not so... so far I'm at this-
and the tester -public class chapter7number10 { public chapter7number10(int a) { factor = a; } public void hasMoreFactors() { do { nextfactor(); System.out.println("one of the factor's is " + afactor); } while(afactor < factor); } public void nextfactor() { for(countingnumber = currentfactor; factor > countingnumber; countingnumber++) { currentfactor = currentfactor + countingnumber; if(factor % currentfactor == 0) { afactor = currentfactor; } } } int factor; int afactor = 0; int currentfactor = 1; int countingnumber = 1; }
this is printing an infinite loop of the first factor and i need it to print all the factors excluding 1 and itself then stop, please help.