Subgoals

Section8.2Write-Methods-WE1-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

Subsection8.2.1

GIVEN
For questions 1 through 3, fill in the blanks of the following code, which is a public method header for the method politics that returns a String and doesn’t accept any parameters.
___A___ ___B___ politics (___C___) { /* logic */ }


ExercisesExercises

1.
Q1: Fill in Blank A.
• public
• private
• String
• void
• nothing, empty
2.
Q2: Fill in Blank B.
• public
• String
• double
• void
• nothing, empty
3.
Q3: Fill in Blank C.
• public
• private
• String
• void
• nothing, empty
GIVEN
For questions 4 through 8, fill in the blanks of the following code, which is a public that returns an integer and requires as parameters one integer, one double, and one String (in that order) and calculates the weight of the stress on your shoulders.
___A___ ___B___ backpain (___C___ one, ___D___ two, ___E___ three)
{
/* logic */
}

4.
Q4: Fill in Blank A.
• public
• private
• String
• int
• double
5.
Q5: Fill in Blank B.
• public
• private
• String
• int
• double
6.
Q6: Fill in Blank C.
• String
• int
• double
• void
• nothing, empty
7.
Q7: Fill in Blank D.
• String
• int
• double
• void
• nothing, empty
8.
Q8: Fill in Blank E.
• String
• int
• double
• void
• nothing, empty
GIVEN
For questions 9 through 12, fill in the blanks of the following code, which is a private method header that returns a String and requires as parameters a double and a String (in that order) and calculates the temperature of a planet at dusk on the third monday of the current month.
___A___ ___B___ leonardo (___C___ one, ___D___ two) { /* logic */ }

9.
Q9: Fill in Blank A.
• public
• private
• String
• int
• double
10.
Q10: Fill in Blank B.
• public
• private
• String
• int
• double
11.
Q11: Fill in Blank C.
• String
• int
• double
• void
• nothing, empty
12.
Q12: Fill in Blank D.
• String
• int
• double
• void
• nothing, empty