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