Unit 7 Assignment#
Reading#
Eck Section 7.1 (Arrays) http://math.hws.edu/javanotes/c7/s1.html
Wikibooks Java - Arrays https://en.wikibooks.org/wiki/Java_Programming/Arrays
Codingbat practice#
arrayCount9
arrayFront9
array667
Code#
Make sure to write full unit tests for these functions.
Count lucky#
A number is lucky if it is a multiple of 7 or ends in 7. Write a function that counts the number of lucky numbers in an array of integers.
countLucky({1, 2, 3}) -> 0
countLucky({7, 13, 17}) -> 2
countLucky({107, 207}) -> 2
Sum of squares (array)#
Write a function that takes a single array of doubles as input, and returns the sum of squares of the values.
sumOfSquares({0}) -> 0
sumOfSquares({1.0, 2.0, 3.0}) -> 14.0
sumOfSquares({2.0, 2.0, 2.0}) -> 12.0
Total Z name length#
Write a function that takes an array of strings as input, and returns the total length of the strings that start with “z” or “Z”.
countZNames({"Dr. Kessner", "Dr. Sands"}) -> 0
countZNames({"Zorro", "zero", "zippy"}) -> 14
Project#
It’s time to start planning and prototyping your coding project!
Your project can be any interactive animation or video game using the Processing libraries.
Your goals for the week:
Start your project! Make a folder, and get some code running, even if it’s just a title screen and a bouncing ball.
Make sure you understand how to use the Processing libraries in your program. In particular, you will need to understand how to write classes that call the Processing functions via a PApplet reference.
Play around with some ideas.