Homework 3, Year 2

Have these done by next class. Email me your working code.

Prime Number Problem

Your first homework problem is going to be writing a function
that takes in an integer i, and returns true if the integer is
a prime number.

A prime number is a number that is only divisible by 1 and itself.

Please use the internet as a resource to solve this problem!
You can even copy code if you'd like. But the only rule is that your
solution must be in Processing. Submitting code that does not work
in Processing will not recieve any credit.

There are lots of ways to solve this problem. Use solutions implemented
in other languages online for inspiration!

One way to implement the solution is :
if you want to find out if the integer n is prime,
divide n by every number between n-1 and 2.
If any of those divisions result in a number that does not have
a decimal, n is not prime.

The function must return a boolean. It must take in exactly 1 int as a parameter

Space Background

The next problem can be programmed however you want.
However, I will give you tips on how to accomplish it.

The goal is to create a white background with back dots on the screen.
The black dots should move right accross the screen at random speeds,
so that each dot has a random speed that it moves at accross the screen

The desired effect is that the dots will create a parrallax effect by
moving at different speeds. It will make the screen look deep.

You can draw the dots on the screen using ellipse(...). Make their radiuses 5 by 5.

You're welcome to implement this however you'd like, but here are some ideas :
You should probably create a class, Dot that can be used to represent each dot on the screen.
Dot should probably have variables x, y, and speed.
You should create many dots, and then draw them in the draw function.
Move them accross the screen by adding their speed to their x.
Don't forget to initialize their x, y, and speed variables!
When a dot gets off the right side of the screen, you'll have to move it off the left side of the screen.