Listing prime numbers up to the given number
The first thing I'd suggest is break out code segments into functions.  This keeps your Main free of clutter and makes the flow easier to understand.

You don't mention which IDE you're using.  If it doesn't have the option for you to format your code according to acceptable guidelines, I would seriously consider changing programs.  There are several well established IDE's freely available.

Your, check for prime, algorithm, while naive, could do with some optimization.  Check for 0,1, and 2 separately.  If the number is bigger than 1 then add 2 to the list.  The loop should start at 3 and step by 2.  As was pointed out, all primes larger than 2 are odd.

There are much better algorithms for getting a list of prime numbers, not the least of which is the Sieve of Eratosthenes.  With this algorithm it is very easy to make a master list of primes then build the sublist that you want.