CI401 Introduction to Programming - Week 2
Input and Repetition: Scanner + While Loop
Commented lab code (read the files in this order)
=================================================

Every file starts with "// What this class does", then short comments on
the Java bits that look strange if you only know Python.
The "_explained" files are FINISHED answers. Try each exercise yourself in
the original scannerWhile project first, then compare with these.

FILES IN READING ORDER
----------------------
Lecture and lab examples (read and run these first)
 01  Step01_ScannerTemplate.java      - the empty starter for any Scanner program
 02  Step02_SayHello.java             - ask for a name, say hello (Scanner, next())
 03  Step03_TripAdvisor.java          - place + star rating, fall-through switch
 04  Step04_HelloEverybody.java       - while loop that stops when you type bye
 05  Step05_Santa.java                - while loop that counts down (Ho! Ho! Ho!)

Lab exercises - finished versions
 06  Step06_QueenBot_explained.java            - Ex_QueenBot: name + job, inside a while loop
 07  Step07_QueenBot_Switch_explained.java     - Ex_QueenBot with a switch for special jobs
 08  Step08_HouseTour_IfElse_explained.java    - Ex_EstateAgent_To_HouseTour with if / else if / else
 09  Step09_HouseTour_Switch_explained.java    - the same HouseTour with switch / case / break
 10  Step10_DrawSquare_WhileSwitch_explained.java - Ex_DrawSquare (extension), first try: breaks above 5
 11  Step11_DrawSquare_2Whiles_explained.java     - Ex_DrawSquare (extension), fixed: loop inside a loop

OPTIONAL challenges (only if you want more)
 12  Step12_OPTIONAL_SpecialNames_explained.java  - lecture challenge: Tom -> Jerry, Harry -> Ron
 13  Step13_OPTIONAL_SantaAsks_explained.java     - Santa challenge part 1: you choose how many Ho!s
 14  Step14_OPTIONAL_SantaRepeat_explained.java   - Santa challenge part 2: keep asking until 0 or less
 15  Step15_OPTIONAL_CityRatings_V1_explained.java - Ex_CityRatings_Challenging, version 1 (simplest)
 16  Step16_OPTIONAL_CityRatings_V2_explained.java - version 2: asks y/n again if the answer is wrong
 17  Step17_OPTIONAL_CityRatings_V3_explained.java - version 3: checks everything, exit stops at once

(package.bluej is only there so BlueJ opens this folder as a project.)

HOW TO OPEN AND RUN IN BLUEJ
----------------------------
1. Open BlueJ.
2. Click Project, then Open ZIP/JAR...
3. Pick CI401_Week2_Commented_Lab.zip and click Open.
   (BlueJ unpacks it and shows one box per class.)
4. Click Compile (the button on the left). Striped boxes turn plain when compiled.
5. Right-click a class box, for example Step02_SayHello.
6. Click void main(String[] args), then OK.
7. The terminal window opens. Type your answer at the bottom and press Enter.
   To stop a program that is stuck in a loop: right-click the striped bar at the
   bottom right of the BlueJ window and choose Reset Java Virtual Machine.

GLOSSARY
--------
class          The box that holds a program. In Java all code lives inside a
               class. The class name must match the file name exactly
               (class Step02_SayHello lives in Step02_SayHello.java).
method         A named block of code you can run, like a Python def.
               run() and main() are methods. next() is a method of Scanner.
main           The special method Java starts from:
               public static void main(String[] args). BlueJ shows it as
               void main(String[] args) when you right-click a class.
String         Text, such as "bye" or a name. Written in double quotes.
               Capital S. Like Python str.
int            A whole number such as 5 or -2. Like Python int, but Java makes
               you say the type: int x = 5;
array          A fixed-length list of values of one type, for example
               String[] cities = {"London", "Paris"}; Like a Python list,
               but it cannot grow or shrink.
semicolon      The ; at the end of each Java statement (each instruction).
               It tells Java "this instruction ends here". Python uses the
               end of the line instead. Forgetting it is the most common error.
curly brackets { } mark where a class, method, loop or if starts and ends.
               Python uses a colon and indentation instead. Every { needs a }.
.equals        How you compare two Strings in Java: name.equals("bye").
               Do NOT use == for text. == checks whether they are the very
               same object in memory, which can be false even when the
               letters match. !name.equals("bye") means "name is not bye".
