Computer Science 210
Data Structures

Fall 2017, Siena College

Lecture 03: Java Review: Arrays and Methods
Date: Monday, September 11, 2017


Agenda

Lecture 03 Assignment

Due at the start of class, Friday, September 15.

Please submit answers to these questions by the start of class. zyBook activities should be done right in your zyBook, and all others should be submitted to Blackboard under "Lecture 03 Assignment" . We will discuss these questions at the start of class, so no late submissions can be accepted.

Read J+DS zyBook Chapter 8.

You are welcome to do any "Participation Activities" that you believe would be helpful, but those will not count for grading.

Please complete all "Challenge Activities" in Chapter 8. This will be worth a total of 30 "Assignment" points, with your score based on the percentage of tests your responses pass.

Also complete the following:

  1. What is printed by this program? (8 points)
    private void mystery() {
        int [] report = { 5, 4, 10, 4, 6, 3, 4 };
        int turn = 0;
        int shot = 0;
        int lastTotal = 0;
    
        while (shot < report.length && turn < 10) {
            int increment = report[shot] + report[shot+1];
            if (increment >= 10) {
                increment = increment + report[shot+2];
            }
            if (report[shot] < 10) {
                shot++;
            }
            lastTotal = lastTotal + increment;
            shot++;
            turn++;
            System.out.println(shot + " : " + lastTotal);
        }
    }
    

Terminology

Examples