title: How do i make a composite generator that would output the same way as the prime generator with it?
body: <p>I have been trying to impelement a Composite generator to work along side the prime number generator but I can't seem to figure out how to work it in. Every time I apply another section to the code under <code>if (isPrime) { count++;</code>, I get a else without if statment then the whole program stops working. Any suggestion to my problem?</p>
  
  <pre><code>package primegenerator;
  import java.util.Scanner;
  
  public class PrimeGenerator{
  public static void main(String[] args) {
      Scanner input=new Scanner(System.in);
      double user;`enter code here`
      System.out.print( " Enter any number: " );
      user = input.nextDouble();
      //Saving user's input for generator
      final int NUMBER_OF_PRIMES_PER_LINE = 10; //Display 10 per line
      int count = 0;
      int number = 2;
  
      System.out.println("Your Prime numbers are: \n");
  
      //Reapeatedly find prime numbers
      while (count &lt; user) {
          //Assume the number is prime
          boolean isPrime = true; // Is the current number prime?
  
          //Test whether number is prime
          for (int divisor = 2; divisor &lt;= number / 2; divisor++) {
              if (number % divisor == 0) { //If true, number is not prime
                  isPrime = false; //Set isPrime to false
                  break; //Exit the for loop
              }
          }
  
          //Display the Prime number and increase the count
          if (isPrime) {
              count++; // Increase the count
  
              if (count % NUMBER_OF_PRIMES_PER_LINE == 0) {
                  //Display the number and advance to the new line
                  System.out.println(number);
              //Displays all primes by 10 a line
              }
              else
                  System.out.print(number + " ");
  
              }
              //Check if the next number is prime
              number++;
          }
      }
  
  }
  </code></pre>