Skip to main content

Section 8.8 Write-Methods-WE3-P1

Subgoals for Writing Methods.

  1. Define method header based on problem
  2. Define return statement at the end
  3. Define method body/logic
    1. Determine types of logic (expression, selection, loop, etc.)
    2. Define internal variables
    3. Write statements

Subsection 8.8.1

Exercises Exercises

1.
Q46: Put the code in the right order to create a program that has a public method that returns a String and accepts an integer parameter and returns a flavor of ice cream. There is also a main program that calls the method twice.
2.
Q47: Put the code in the right order to create a program that returns a String and accepts as parameters a double and a String, and concatenates the two values as a temperature along with its base scale. There is also a main program that calls the method twice, once with Celsius and once with Fahrenheit.
3.
Q48: Put the code in the right order to create a program that returns a double, and accepts as parameters 3 integers, and calculates the average of the inputs. There is also a main program that calls the method twice with different values.
You have attempted of activities on this page.