Assignemnt #106

Code

          /// Name: Holden Ganch
          /// Period: 7
          /// Program Name:  one hundred and sixth program
          /// File Name: Prime.java
          /// Date Finished: 3/30/2015


    
                   import java.util.Scanner;
        
        public class Prime
        {
            public static void main(String[] args)
            {
                for (int n = 2; n <= 20; n++)
                {
                    if (isPrime(n) == true )
                        System.out.println(n + " <");
                    else
                        System.out.println(n);
                        }
            }
               public static boolean isPrime( int n )
               {
                   boolean result;
                int x = 0;
            for ( int a = 2; a < n; a++)
            {
                if ( n % a == 0)
                    x++;
                else
                    x=x;
            }
            if ( x > 0)
                result = false;
            else
                result = true;
            return result;
        }
        }
            




    

Picture of the output

Assignment 106