American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – Intro to Java – Roland

April 3 @ 7:00 pm - 8:00 pm

Today We Did
    1. For loops
      1. Looping through lists
        1. for (datatype var_name : list_name) { }
        2. for (int i = 0; i < list.size(); i++) { }
        3. for (int i = list.size() – 1; i >= 0; i–) { }
      2. Using numbers
        1. Incrementing forwards
        2. Incrementing with different values besides 0
        3. Decrementing/Reverse
    2. While loops
      1. Using numbers
      2. Infinite loops asking user for input
        1. Checking input directly
        2. True/break
        3. Boolean flag
    3. Number 3 GameInventory problem from homework
      1. https://www.ayclogic.com/java-list-forloop/
      2. Refer to GameInventory.java in Notes below for final solution
Homework
  1. Create a new Java file April3_LoopHW.java and complete the problems in (https://www.ayclogic.com/java-exercise-while-loop/) (listed below)
    1. Create a forever loop that will keep asking a user the following question:
      1. What grade did you get on your Java test?
      2. If the user answers with a grade that is bigger or equal to 90 then
        1. print “Good job, you can take a good rest and play your video games all day long”.
        2. stop the loop.
      3. If the user answers with a grade that is between 80 to 90 then
        1. print “Not bad, but I am sure you can do better. Why don’t you study a little bit more and retake the test.”
      4. If the user answers with a grade that is between 70 to 80 then
        1. print “I think you need to study a lot harder and retake the test.”
      5. If the user answers with a grade that is lower than 70 then
        1. print “All right you are grounded, no video games for 1 year and no computer”.
        2. stop the loop.
    2. In the above exercise, you should only stop the loop when the user get above 90 or below 70.
  2. Upload your answer to google drive before next week Tuesday night.

If you have any questions feel free to email me rolandyang@ayclogic.com

Feel free to reference the code in the notes if you are lost (April3_Loops.java): https://drive.google.com/drive/folders/10JdSDu9bC5k_Jewi3BxazkkuBNrrVpqA?usp=sharing

Details

Date:
April 3
Time:
7:00 pm - 8:00 pm
Verified by MonsterInsights