APCS Unit 5
Arrays Introduction

 Download the Unit 5 Rubric

 Unit 5 Quiz Coming Soon!

Welcome to the 5th unit of AP Computer Science! We’ve covered a lot this semester – from Jeroos and basic Java programs, to control structures and object oriented design.  Next on the list though is a new tool for storing information that will make it much easier to store large groups of data in just a few variables. For this, we’ll use something called arrays. Arrays are data structures in programming that have the following characteristics:

  • They have a single name for the entire array (list)
  • They can reference each spot individually
  • They start counting their spots at ‘location 0’
  • They all have a non-negative length

As we practice with arrays and try to do various things with them, we’ll need to be able to do a few very specific tasks:

  1. Create arrays with the values we want
  2. Recall or change the values within an array
  3. Print an entire array using a ‘for’ loop
  4. Traverse an array to look at each spot

Once we’ve tackled these skills, we’ll be able to use arrays for all sorts of good things!

Part 1: One-Dimensional Arrays

Array Examples

Here in the first part of the unit, we need to get used to something called a 1-dimensional array.  The 1-dimensional arrays act like lists where you can have multiple (potentially a lot) of values stored within a single variable.  This array is great if you need to store a lot of grades for a single student, a lot of names for a single high school course, or a lot of prices for goods within a single store.  The uses for 1-dimensional arrays are many, and to get started we need to know how to make them, how to change them, and how to use the elements inside them!


 Take a page of notes on Arrays and the ideas presented in the videos below and in class

 Complete the 8 Java tasks about arrays

 Complete 8 challenges in the Java -> String 3 section on codingbat.com

 Have Mr. Benshoof check off your completed tasks

Traversing 1-Dimensional Arrays

Classes & Arrays

Part 2: Multi-Dimensional Arrays

BlueJ Reference

The second part of our unit is all about making parts of the program repeat.  These "loops" can cause a section of the program to repeat itself a different number of times.  One of the challenges is to use a loop that gives you the kind of control that you want.

The WHILE loop (sometimes called sentinel controlled repetition) uses a counter to keep track of how often the program has run.  Once the counter (or another variable) reaches a threshold, the loop finally stops.

The FOR loop (sometimes called counter-controlled repetition) uses a variable to count the number of times the loop has repeated.  Once the counting variable reaches its limit, the loop ends and the program continues.

These two looping structures are the focus of this part of the unit, and will be important tools throughout the rest of the year!


 Watch the videos on loops and looping control structures.  Take a full page of notes on these topics as you watch them.

 Complete Java Task 16: Even/Odd

 Complete Java Task 17: Sum & Average

 Complete Java Task 18: Odd Counter

 Complete Java Task 19: Multiplication Chart

 Complete Java Task 20: Random Grid

 Complete Java Task 21: 12x12 Grid

 Complete Java Task 22: Alternating Grid

 Complete Java Task 23: Small Rectangle

 Have Mr. Benshoof check-off your completed Java challenges

 Complete the short Control Structures Assignment

 Take the Unit 3 Quiz

While Loops

For Loops

Nested For Loops

Part 3: Tic-Tac-Toe

The final part of our unit is to use the control structures we've studied to make a working Gradebook program! The gradebook you make needs to meet the criteria listed in the unit paperwork.  Specifically:

  1.   Let the user enter a variety of assignment types (at least 2: quizzes and homework).
  2.   Let the user enter a variety of assignment grades
  3.   Let the user enter the grades and assignments in any order
  4.   When the user is done entering assignments, the program should tell them some information:
    1.   How many assignments were listed for each type (how many quizzes, how many homeworks, etc)
    2.   How many of the total list of assignments were A’s, B’s, C’s, D’s, or F’s
    3. What the average score (based on either points OR percentages… whichever you like best) on all assignments was
    4. Assuming the upcoming final would be worth 15% of the course grade (and all entered assignments were the remainder of the grade), what grade would the student need on the final to earn their desired course grade.
  5. The program should be relatively easy to use and easy to understand.


APCS Unit 5 Map
Looking for something?  Here you'll find a library of links to all the documents, images, and videos needed here in APCS Unit 5.