Lesson 14 – Nested loops

Big Java 6

When you come in

  1. Connect to the Internet
  2. Log in to Piazza
  3. Start Bluej
  4. Navigate to laughton.com/obrien/sjsu/
    cs46a/fall16/lessons and open this lesson

Questions

Activity - Nested Loops

Record your participation in Piazza clicker question Lesson14 Q1

Write a pair of nested loops to print the following pattern. We will do it together

1 
1 2 
1 2 3  
1 2 3 4
1 2 3 4 5 
1 2 3 4 5 6  

Activity - Nested loops

Record your participation in Piazza clicker question Lesson14 Q2

Write nested loops that make the following pattern of brackets: (Note: there are no spaces)

[][][][]
[][][][]
[][][][]

  1. Got it
  2. Got it but it was hard
  3. Couldn't do it in the time allowed
  4. Didn't know where to start

 

Concept - Random numbers

 

 

Activity - Random numbers

Record your participation in Piazza clicker question Lesson14 Q3

Write the segment of code to generate a random integer. Unless otherwise stated, the range is inclusive of the first number and exclusive of the last number

 

Program with a bug

Record your participation in Piazza clicker question Lesson14 Q4

 

Activity - Using the Bluej debugger - MagicPotion

Record your participation in Piazza clicker question Lesson14 Q5

 

Activity - Using the Bluej debugger - StringIndexOutOfBounds

Record your participation in Piazza clicker question Lesson14 Q6

This program throws an exception.

Can youuse the debugger to find out why?

  1. Figured it out
  2. Figured it but it was hard
  3. Couldn't do it in the time allowed
  4. Didn't know where to start