I'm trying to write a program that first decides if a number is prime, and if it is writes it to a file I created. I'm obviously having problems (or I wouldn't be pulling my hair out and posting this). First, the errors say an identifier expected after the "public static void prime(isPrime, int number)" and "public static void noPrime(isPrime, int number)" lines. After that, I'm sure it's all messed up. Any help? Thanks.
import java.util.Scanner;
import java.io.*;
public class primeNumberToFile
{
public static void main (String[ ] args)
{
//variables
int num;
//Call methods in main
prime(isPrime);
noPrime(isPrime);
}//end class
// Determine whether it is prime or not.
public static boolean isPrime (int number)
{
//Create Scanner object for keyboard
Scanner keyboard = new Scanner(System.in);
//Get integer from user.
System.out.println("Please enter a positive integer: ");
number = keyboard.nextInt();
boolean isPrime;
for (int x=2; x < number; x++)
{
if (number%x<0)
isPrime = true;
else
isPrime = false;
}
return isPrime;
}//end class
//If the number is prime, tell that to user, the write that number to a file.
public static void prime(isPrime, int number)
throws IOException
{
int number;
System.out.println(number + " is prime.");
//Open the file.
PrintWriter outputFile = new PrintWriter("PrimeNumbers.txt");
while (number <=100 && number >=1);
{
//Write number to the file.
outputFile.println("PrimeNumbers.txt");
//Close the file.
outputFile.close();
System.out.println("Numbers written to file.");
}
}//end class
//if the number is not prime, tell the user that.
public static void noPrime(isPrime, int number)
{
System.out.println(number + " is not prime.");
}//end class
}//end main