signatures · Math calls · random ranges · String methods
Pull the method apart before you ever try to call it.
1. Identify the method name in each signature.
2. Count how many parameters each signature has.
3. Describe the parameter types and the return type for each one.
Move from reading signatures to building a valid call yourself.
1. Write one valid call for each signature.
2. Store the returned value when a method gives one back.
3. Call the void method as a statement by itself.
4. Write your three finished calls in code comments.
Use several Math calls together to build real expressions.
1. Create a variable named distance for the formula sqrt(rise² + run²).
2. Create a variable named penalty for the formula abs(-4.5) * level.
3. Create a variable named score for the formula pow(abs(rise - run), 2) / level.
4. Print all three results after the formulas are complete.
Use a real geometry formula that depends on several steps.
1. Create three variables for the side lengths 13, 14, and 15.
2. Create a variable named s for the semiperimeter formula (a + b + c) / 2.0.
3. Use the formula sqrt(s(s-a)(s-b)(s-c)) to compute the triangle area.
4. Print the final area.
Some method calls fit these variables, and some do not.
1. Inspect every line and decide which variable types are already correct.
2. Repair only the lines whose variable types do not match the returned value.
3. Keep every method call exactly the same.
4. Compile and run only after you finish the fixes.
Some random formulas almost work, but one tiny detail breaks the range.
1. Inspect each expression and decide whether it really builds the intended integer range.
2. Fix the broken lines without changing the target ranges.
3. Keep any line that is already correct.
Turn one random double into the exact integer range you need.
1. Create die so it can be any integer from 1 to 6.
2. Create ticket so it can be any integer from 20 to 29.
3. Create room so it can be any integer from 300 to 399.
Create one extra string, then use one object in several different ways.
1. Create one more String variable with a literal before you begin.
2. Print the length of word.
3. Print the letters from index 2 through index 4.
4. Print everything from index 4 to the end.
5. Print the first location of the letter "o".
6. Decide whether word has the same text as "robotics".
Use string comparisons to decide sameness and alphabetical order.
1. Create a variable named sameText to test whether first and third have the same text.
2. Create a variable named order to compare first and second alphabetically.
3. Print both variables.
4. Decide which word should appear first in sorted order.
Use substring pieces to build a target word in the correct order.
1. Create a new String result using only pieces of original.
2. Make the final printed word become HIDE.
3. Print the finished value of result.
Pull several useful pieces out of one compact string.
1. Create a variable named state for the first two letters.
2. Create a variable named number for the middle three digits.
3. Create a variable named section for the last letter.
4. Print all three extracted pieces.
Use a one-character substring when a full slice would be too wide.
1. Create a variable named row for the first character.
2. Create a variable named gate for the last character.
3. Keep both results as String values, not chars or numbers.
Compare the two lines and figure out what actually changed.
1. Run the program exactly as written.
2. Compare the first printed line and the second printed line.
3. Explain why the original string stayed the same until the new result was saved.
Mix string concatenation with escape characters to match a target display.
1. Create variables for a student name, a club name, and a rank number.
2. Print the three-line status card shown at the right with one println statement.
3. Use escaped quotes and line breaks so the output matches exactly.
A blank string and a missing string do not behave the same way.
1. Predict what each line will do before you run the program.
2. Identify which line is still safe even when the variable does not point to a real string.
3. Fix the broken line so the program can still finish safely.