Homework 5

Please complete this homework before next class.



General Review Problems

1. Create an ArrayList that can store integers.

2. Fill the ArrayList with 100 random numbers.

3. Print out all the numbers in the list.

4. Write a program that prints "Harambe" every 1 second.

5. How can we write a for loop that prints all the numbers between 10 and 100?

6. [Hard] Write a program that has prints out "Dark Voyager" exactly 50% of the time.

7. [Hard] Write a program that adds together all the numbers between 0 and 100. Print the result.

8. Create an array of 50 strings. Set the last element in the array to be "Hello".

9. How do we get the size of an array?

10. How do we get the size of an ArrayList?


Multidimensional Problems


These are hard. Good luck.

1. Create a 2D array of integers that is 5 by 5.

2. In the array, set the second element in the second array to be 135.

3. Create a 2D array of integers that is 50 by 50.

4. Write a 2D loop that sets all of the integers in the array to be random.

5. [Very Hard] Write a multidimensional loop that outputs the following pattern :
0
1
2
0
2
4
0
3
6
0
4
8
0
5
10

6. Create a 5 dimensional array of Strings.

7. [Hard] Create a String array of size 50. Set every element in the array to be
i number of the letter 'a'.
Ex : array[0] should = ''
array[1] should = 'a'
array[2] should = 'aa'
array[3] should = 'aaa'


Final Problem

You must work on a game. You need to develop a small game on
your own. This will give you practical experience that programming problems won't.
I'm very sure that all of you have the skills to make a simple game. Even if you
fail at making a game, just trying will give you a ton of practice that will help you be a better programmer.