Week 1 · Friday, Jan 8 · 1.5
Expressions and output
print stays on the line and println ends it; a string literal prints what is between its quotes, with \" \\ and \n for a quote, a backslash and a new line; and int / int keeps only the whole part, while % gives the remainder.
Minutes for each part of a 90-minute class.
Today we will
- System.out.print shows its value and stays on the line. System.out.println shows its value, then moves to a new line.
- A string literal is text in double quotes. Inside it, \" prints a quote, \\ prints a backslash and \n starts a new line.
- Arithmetic: + - * / %. Two ints give an int, so 7 / 2 is 3. If either value is a double, 7.0 / 2 is 3.5.
- % gives the remainder: 7 % 2 is 1.
- *, / and % go before + and -, left to right. Parentheses go first of all.
- Dividing an int by the int 0 stops the program with an ArithmeticException, a run-time error.
Terms
AP topics 1.3 · Learning objectives 1.3.A, 1.3.B, 1.3.C · Skills 2.A, 3.A, 3.D
Demonstration
Chromebooks open. Follow along on the Follow along jobs in We Do / You Do while Mr. Muggivan works the examples.
We Do / You Do
Follow along, then Part A (with help), Part B (on your own) and stretch. One code for the whole block.
Open We Do / You DoExit Ticket
A few exam-style items to show what you learned today. One code.
Opens only in the last 15 minutes of class on this day.
Missed class? The Do Now and We Do / You Do stay open. Do them any time and submit your codes.