In my first program I was asked to output the perfect squares less than the value n.

Code :

int i = 0; int x = 0; int n = in.nextInt(); while (i < n) { i = x*x; System.out.print(i + " "); x = (x + 1); }

My issue is if I enter 90, it outputs 100. I know this is because after 9*9 it goes to 10*10 but how can I change it so it doesn't do this?

My second issue is a bit more complicated and I have no idea what to do. I have to output all positive numbers divisible by 10 less than n:

Code :

int i = 0; int x = 0; int n = in.nextInt(); while (i < n && i > 0) { i = x/n; if (i%10==0) { System.out.print(i + " "); } else { x = (n-1); } }

my output is all zeros. Why?! How do I fix this?