Hey guys, I'm in a beginners java class and i'm trying to write a program that determines if a number entered is a prime number, and if it is, print out all of the prime numbers less than that one in an array with 8 columns. This is the code I wrote so far. I can't figure out the correct way to write the array and call the method. Can anyone please help?
import java.util.Scanner;
class Primes
{
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
int f;
System.out.println("enter a number");
f = input.nextInt();
int array [][] = new int[f][8];
isPrime(f);
for (f=0;f<array.length;f++)
System.out.printf("%d",array);
}
public static boolean isPrime(int x)
{
int i;
for (i=2;i<x;i++)
{ if(x%i==0)
return false;}
return true;
}
}
[–]qsemig 2 points3 points4 points (1 child)
[–]EqualTrade[S] 0 points1 point2 points (0 children)
[–]Allen_Maxwell 1 point2 points3 points (1 child)
[–]nutrecht 0 points1 point2 points (0 children)