Hey for hw i gotta do a program that spits out the perfect squares between 0 and a number entered... well i got it done but it spits out 1 extra number that goes OVER what the person entered... here's my code.
public static void main(String[] args)
{
String userinput = JOptionPane.showInputDialog("Enter a positive integer");
int j = Integer.parseInt(userinput);
String space=" ";
String num="";
int b=0;
for (int i =1; b < j; i++)
{
b = i * i;
String numst = Integer.toString(b);
num += " " + numst;
}
System.out.println(num + " are all the perfect squares between " + j);
}
an example is i put i enter 26... it gives me "1 4 9 16 25 36" it should only give me up to 25... any insight would be appreciated.