I have the code to print prime numbers but I can't figure out how to print the numbers 8 to a row. This is because I have to find all the prime numbers <200.
import java.util.Scanner;
public class PrimeNumbers
{
public static void main(String[] args)
{
Scanner input = new Scanner( System.in );
//initialize variables
int Number, Temp=1, Prime=3;
System.out.print("Enter the number of prime numbers to display: ");
Number=input.nextInt();
if (Number>=1)
{
System.out.println("The first"+Number+" prime numbers are: ");
System.out.println(2);
}
for (int count=2;count<=Number;)
{
for (int x=2;x<=Math.sqrt(Prime);x++)
{
if(Prime%x==0)
{
Temp=0;
break;
}
}
if (Temp!=0)
{
System.out.println(Prime);
count++;
}
Temp=1;
Prime++;
}
}
}