Week 14 · 14.4 · Fri, Nov 6 · Do Now
Work every question in your notebook. Do it on your Chromebook with your ID.
Lines of output
How many lines of output does this print? Count an empty line as a line.
System.out.print("X"); System.out.print("Y"); System.out.println(); System.out.println(); System.out.println("Z");- 2
- 3
- 4
- 5
Text or math
What is printed? The first line printed is first.
System.out.println("9 - 2"); System.out.println(9 - 2);- 9 - 2, then 7
- 7, then 7
- 9 - 2, then 9 - 2
- "9 - 2", then 7
Error analysis
A student wanted Go on the first line and Saints on the second line. This code prints GoSaints. What mistake did the student make?
System.out.print("Go"); System.out.println("Saints");- Line 1 uses print, which does not end the line.
- Line 2 should use print instead of println.
- The student forgot a space inside the quotes.
- Java printed the two words in the wrong order.
Pick the code
Which pair of lines prints Red Beans on one line, with one space between the words?
- print("Red ") on line 1, then println("Beans") on line 2
- println("Red") on line 1, then println("Beans") on line 2
- print("Red") on line 1, then println("Beans") on line 2
- println("Red ") on line 1, then print("Beans") on line 2
Output
Trace these lines. Write exactly what is printed, one line of output at a time, and leave the empty line in.
System.out.print("Go "); System.out.println("Saints"); System.out.println(); System.out.println(5 + 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 filled in what each symbol does. Talk with your partner: which row is wrong?
The student's table Symbol What it does ; ends a statement { } group lines into one block " " mark text to show exactly as written ( ) hold the method's name - The ( ) row
- The ; row
- The { } row
- The " " row
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 changed the last row to this. Is it right now?
The student's new last row Symbol What it does ( ) hold what the method is given, like the text to print - Right: ( ) hold what the method is given, like the text to print
- Still wrong: ( ) end a statement
- Still wrong: ( ) group lines into a block
- Still wrong: ( ) mark text