Expressions and Output
Popcorn Hack 1
Popcorn Hack 2
Homework Hack 1
- Predict Output: What will this print?
System.out.print("AP "); System.out.println("CSA"); System.out.println("Rocks!"); - Fix the Bug: The following is supposed to print
C:\Users\Student, but it fails. Correct it:System.out.println("C:\Users\Student"); -
Menu Hack: Add a 4th option (
Settings) toMenu.javaand updateoptionCountaccordingly. - Challenge: Use
System.out.printfto print pi with 2 decimals.System.out.printf("Pi = %.2f\n", Math.PI);
Homework Hack 2
- Expand
Menu.javainto a calculator menu:- Print a menu with options:
Add,Subtract,Multiply,Divide. - Ask the user for two numbers.
- Use arithmetic expressions to compute and display the result.
- Example run:
```
==== Calculator Menu ====
- Add
- Subtract
- Multiply
- Divide Choose an option: 1 Enter first number: 10 Enter second number: 5 Result: 15 ```
- Print a menu with options:
Homework Hack 3 Game
Here is the game that you will also be playing, to test your understanding of the lesson. You will screenshot the game score and submit it to the 1.3 google form (this will alos include 1.4 content, submission is for both)