Skip to main content

Section 9.6 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 9.6.1

Exercises Exercises

1.
Q46: Put the code in the right order to create a public method that returns a String and accepts an integer parameter and returns a flavor of ice cream. The method is called from main as follows:
System.out.println(flavors(1));
System.out.println(flavors(5));
2.
Q47: Put the code in the right order to create a method 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. The method is called from main as follows:
System.out.println ( temps(32.5, "F"));
System.out.println ( temps(0.05, "C"));
You have attempted of activities on this page.