American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – Intro to Java – Roland

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

Today We Did
    1. Reviewed Method HW from last week
      1. Converting from Fahrenheit to Celsius
      2. Converting from Celsius to Fahrenheit
      3. How to run the method
    2. Converted Magic8Ball program to use Methods
      1. run()
      2. provideResponse() and getUserInput()
    3. Did more method practice problems
      1. Format Full Name (return String)
      2. Convert Days to Seconds (return Int)
Homework
  1. Create a new Java file April24_TellMeYourAgeOOP.java and create the Tell Me Your Age program with methods below
    1. The Tell me Your Age program should ask the user “How old are you?: “
    2. If the user responds with “quit” the program should print “bye bye” and break out of the loop
    3. Otherwise it should give a response according to the following below
      1. If the user is 0 years old, it says “You are a new born baby.”
      2. Else if the user is younger than or equal to 4 years old, it says “You are a toddler”
      3. Else if the user is younger than or equal to 12 years old, it says “You are a kid”
      4. Else if the user is younger than or equal to 20 years old, it says “You are a teenager”
      5. Else if the user is younger than or equal to 30 years old, it says “You are a young adult”
      6. Else if the user is younger than or equal to 60 years old, it says “You are an adult”
      7. Else it says “You are a senior”
    4. Convert the program we made above into an OOP program with methods! like how we did splitting our 8Ball program up in class:
      1. create run() method
        1. This method should store the infinite while loop that asks the user and provides responses
      2. create getUserInput() method
        1. Should ask the question “How old are you? ” and return a string with the user’s input using Scanner to get the input
      3. create provideResponse() method
        1. This should take in the user’s input as a parameter and provide an appropriate response depending on their age using the algorithm above
        2. Should be a void method that just prints the response
      4. And call the run() from main() as we did in class
  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 (April24_MethodsContinued.java): https://drive.google.com/drive/folders/10JdSDu9bC5k_Jewi3BxazkkuBNrrVpqA?usp=sharing

Details

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