Please complete this homework before next class. I will be posting the
solutions after next class.
Problem set A
1. Write a while loop that prints all of the numbers between 0 and 100.
2. Modify the while loop so that it only prints even numbers.
3. Create a String variable called name that equals your name.
4. Create an int called x that starts at 100.
while x is greater than 0, print x and then decrease its value by 1.
Problem set B
1. Create a function called printHi() that prints out "hi" when called.
2. Create a function that takes in a integer parameter x. The function
should be called printNumbersUpTo and it should print all the numbers
between 0 and x
3. Create a function that sets the background color to blue. It should be called
setBackgroundBlue.
Problem set C
1.) First, create the setup and draw functions.
2.) Next, create four global integers (global means that they're created at the top of the file).
They should be called x, y, speedX, and speedY.
x should start off at 200.
y should start off at 200.
speedX should start off at 5
speedY should start at 5
3.) In the draw function, set the background to blue.
4.) After the background() call in the draw function, draw
an ellipse at x, y with a width of 20 and height of 20.
5.) After you draw the ellipse, you should increase x by speedX
increase y by speedY.
Also :
increase speedY by 1.
6.) The circle should now slide off the screen down and to the right.
Add an if statement so that if y is greater than height, set speedY
to be -20.
7.) Add another if statement so that if the circle's x is greater than
the width of the window, speedX = -5
8.) Add a simmilar if statement so that the circle bounces off the left side
of the screen.
9.) You should now have a bouncing ball : )
If the ball is bouncing weirdly, you may have to modify some of the values.