✕ Close

Week 14 · 14.1 · Mon, Nov 2 · Do Now

Do Now

Work every question in your notebook. Do it on your Chromebook with your ID.

  1. Trace row

    Trace these lines. What do the boxes hold after line 4?

    c ← 37
    k ← 8
    e ← c ÷ k
    ok ← c rem k = 5
    1. c = 37, k = 8, e = 4, ok = true
    2. c = 37, k = 8, e = 5, ok = true
    3. c = 37, k = 8, e = 4, ok = 5
    4. c = 37, k = 8, e = 4, ok = false
  2. Predict

    What is shown? The first line shown is first.

    a ← 9
    b ← a
    a ← a * 4
    show b
    show a rem 5
    1. 9, then 1
    2. 36, then 1
    3. 9, then 7
    4. 36, then 7
  3. Error analysis

    A student traced these lines and wrote that each holds 0. The right answer is 7. What mistake did the student make?

    total ← 45
    bags ← 6
    each ← total ÷ bags
    1. The student divided 6 by 45, upside down.
    2. The student used rem instead of ÷.
    3. The student rounded 7.5 up.
    4. The student skipped line 1.
  4. Pick the rule

    Which question is true exactly when n pieces of candy can be split into groups of 3 with none left over and n is less than 30?

    1. n rem 3 = 0 and n < 30
    2. n ÷ 3 = 0 and n < 30
    3. n rem 3 = 0 or n < 30
    4. n rem 3 ≠ 0 and n < 30
  5. Output

    Trace these lines. Write exactly what is shown, one line for each show.

    candy ← 43
    kids ← 6
    each ← candy ÷ kids
    left ← candy rem kids
    show each
    show left = 1 and each > 7
  6. Turn and Talk, Part 1: What went wrong?

    Turn and Talk · Part 1 · talk with your partner first.

    • “I think the mistake is in line ___ because ___.”
    • “I agree / disagree, because ___.”

    A student wrote this program, and it does not run. Talk with your partner: what went wrong?

    public class Hello
    {
        public static void main(String[] args)
        {
            System.out.println("Hi")
        }
    }
    1. Line 3 should not have (String[] args)
    2. Line 5 is missing its semicolon
    3. The braces on lines 4 and 6 do not match
    4. "Hi" needs single quotes
  7. Turn and Talk, Part 2: Is it right now?

    Turn and Talk · Part 2 · talk with your partner first.

    • “I think it is right now, because ___.”
    • “I think it is still wrong at line ___, because ___.”

    The student added the semicolon and sent this. Is it right now?

    public class Hello
    {
        public static void main(String[] args)
        {
            System.out.println("Hi");
        }
    1. Still wrong: the class's closing brace is gone
    2. Right: it prints Hi
    3. Still wrong: line 5 needs a second semicolon
    4. Still wrong: main must come before the class