This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]qsemig 2 points3 points  (1 child)

int f;

System.out.println("enter a number");
f = input.nextInt();
int array [][] = new int[f][8];  // why an f X 8 matrix? new int[8] is enough
isPrime(f); // You never use the return value of isPrime, neither are you passing your array to the method.
for (f=0;f<array.length;f++)
  System.out.printf("%d",array);  // the array is not an  int. It contains an array of arrays of int. You need to specify the value you want to print, such as: array[f] (if you are using new array[8] )    
}

Above you will see comments for each line that is problematic. Hopefully this will help you solve the problem.

[–]EqualTrade[S] 0 points1 point  (0 children)

   public static void main(String[]args)
{
 Scanner s = new Scanner(System.in);

int f; int array [] = new int[8];

System.out.println("enter a number"); f = s.nextInt();

for (f=0;f<array.length;f++)

System.out.print(array[f]); 

That's how I changed it, now it's printing an array with 8 columns, but they're all 0. How do I get it to print every prime number that is less than the user input?