American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

7 PM – Intro To Java – Gamas

November 18, 2021 @ 7:00 pm - 8:00 pm

Today We Do
  1. we learned about Java methods, with and without return values.
Homework
  1. Create a java file Nov18_MethodHomework.java
  2. Inside this file, create a method
    • favoriteSport(String sport)
    • if the name parameter is “Volleyball” (non-casesensitive) print to the shell “Volleyball is a my favorite sport “.
    • otherwise print to the shell “<sport> is not my favorite sport”
  3. Create another method, this time method with return value:
    • convertFromFahrenheighToCelcius(int fahrenheit)
    • it has one parameter: fahrenheit
    • the formula to convert from fahrenheit to celcius is
      • Celcius = (F - 32) * 5/9
    • So what you have to do is subtract 32 from the parameter fahrenheit and then multiple with 5 and divide by 9.
    • return the calculation.
    • The method needs to return a double data type.
  4. Call each of the methods.
Additional Exercises (Optional)
  1. Inside Nov18_MethodHomework.java, create method “run” which will display below menu continuously and depending on what the user choose, will either call “favoriteSport” or “convertFromFahrenheighToCelcius”.
Select below:
1. Enter your sport
2. Convert Fahrenheit to Celcius
3. Exit
Enter your selection (1,2 or 3): 1

Enter a sport name: Basketball
Basketball is not my favorite sport.

Select below:
1. Enter your sport
2. Convert Fahrenheit to Celcius
3. Exit
Enter your selection (1,2 or 3): 2

Enter a temperature in Fahrenheit: 100
100 Fahrenheit is 37.77 Celcius.

Select below:
1. Enter your sport
2. Convert Fahrenheit to Celcius
3. Exit
Enter your selection (1,2 or 3): 3
Bye bye

Details

Date:
November 18, 2021
Time:
7:00 pm - 8:00 pm
Event Categories:
,
Verified by MonsterInsights