Every time I try to compile my program I get this error "nonstatic method primeNum(int) cannot be referenced from a static context".
In this program, I have to write a method that determines if a number is prime and use this method in an application that determines all the prime numbers between 1 and 100.
Here is my code:
import java.io.*;
import java.util.Scanner;
public class Program7
{
public static void main (String args[])
{
Scanner scanner = new Scanner(System.in);
int x, r=0, prime;
int num[]= new int[100];
while (r<100){
prime=primeNum(x);
System.out.println(prime);
r++;
}
}
public int primeNum (int x){
for(i=1; i<=x; i++){
if(x%i==0)
count++;
return x;
}
if(count==2)
System.out.println();
}
}