Skip to main content

Section 8.3 Write-Methods-WE1-P2

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.3.1

GIVEN
For questions 13 through 17, fill in the blanks of the following code, which is a public method header that does not return anything but accepts as parameters 1 String and 2 doubles, and calculates the speed of a student running to the lunch line.
___A___ ___B___ thingy (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}

Exercises Exercises

1.
    Q13: Fill in Blank A.
  • public
  • private
  • String
  • void
  • nothing, empty
2.
    Q14: Fill in Blank B.
  • public
  • String
  • double
  • void
  • nothing, empty
3.
    Q15: Fill in Blank C.
  • public
  • String
  • double
  • void
  • nothing, empty
4.
    Q16: Fill in Blank D.
  • public
  • String
  • double
  • void
  • nothing, empty
5.
    Q17: Fill in Blank E.
  • public
  • String
  • double
  • void
  • nothing, empty
GIVEN
For questions 18 through 22, fill in the blanks of the following code, which is a public that returns an integer and accepts as parameters one String and two integers (in that order) and calculates how many presents you will give this year.
___A___ ___B___ gifts (___C___ one, ___D___ two, ___E___ three)
{
   /* logic */
}
6.
    Q18: Fill in Blank A.
  • public
  • private
  • String
  • int
  • double
7.
    Q19: Fill in Blank B.
  • public
  • private
  • String
  • int
  • double
8.
    Q20: Fill in Blank C.
  • String
  • int
  • double
  • void
  • nothing, empty
9.
    Q21: Fill in Blank D.
  • String
  • int
  • double
  • void
  • nothing, empty
10.
    Q22: Fill in Blank E.
  • String
  • int
  • double
  • void
  • nothing, empty
You have attempted of activities on this page.