Each week you will complete problem(s) to turn in at your section. These problems will earn you 1 out of your 3 section participation points for the week. The other 2 points are awarded for being present in your section and participating in the discussion.
You will not be graded on whether you have a perfect solution, but on whether you have demonstrated effort. Therefore please show some work that demonstrates how you got the answer rather than just writing the answer by itself. We will be somewhat lenient about exactly how the work is shown.
Exercises: Solve the following three (3) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
Self-Check 8.2: what is an object? (p491). Answer the question in your own words.
Self-Check 8.11: problems with constructor (p492). Write the two problems with the constructor shown, and then show a corrected version that does not contain these two problems.
Self-Check 8.23: copy constructor (p492). Write a Point
constructor that accepts the parameter shown. You don't need to turn in the whole Point
class, just a written copy of your idea for the constructor code.
Exercises: Solve the following two (2) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
Self-Check 7.19: array simulation (p432). Write the final contents of the two arrays after the code is finished executing. Show your work by writing the arrays' initial contents and then crossing out elements as their values change.
Self-Check 7.8: array max (p431). Either write a loose fragment of code (declare an array of values and then discover its max value), or write a max method as described and show one example array declaration and call to the method.
Exercises: Solve the following three (3) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
Self-Check 6.7, 6.8, and 6.9: File processing (p370). For each of the three problems, write the output from the code shown. You do not need to show your work; just the answer.
Exercises: Solve the following one (1) Self-Check problem on paper and bring your sheet of paper to your section on Thursday:
Self-Check 5.26: Logical Assertions (p325). Turn in a table or list with your answers. For each of the five labeled points in the program, write ALWAYS (A), NEVER (N), or SOMETIMES (S) for each of the three assertions. In addition to this, show your work by explaining very briefly why you wrote the answer you wrote for each point and assertion. (Example: You could write something like, "for Point C, assertion "k > j
", the answer is SOMETIMES because the value of k
is generated by a Random
object so it could have any value.")
while
, Random
, boolean
(Thu Oct 29)
Exercises: Solve the following two (2) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
Self-Check 3.12: String method calls (p168). This problem shows several method calls on String
variables and asks you to write the result that is returned by each call. Solve only the 1st, 4th, 5th, 8th, 9th, 10th, and 12th bullets. These are the ones that contain the following calls:
str1.length()
str2.toUpperCase()
str1.substring(2, 4)
str1.indexOf(".")
str2.indexOf("donkey")
str3.indexOf("X")
str3.substring(9, str3.indexOf("e"))
Self-Check 5.3: while
loop mystery (p319). Write the output of each call. Show your work by writing a list of each value each variable has as the code is running. One way to do this would be to make a table with each column being one variable, and writing each value that variable takes as the loop is in progress.
The code shown in this problem uses the shortcut operators +=
, -=
, *=
, and /=
as covered in Chapter 2 on p74. For example, x *= 5;
is equivalent to x = x * 5;
.)
if/else
, Scanner
, return
(Thu Oct 22)
Exercises: Solve the following three (3) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
Self-Check 3.7: Temperature
(p167). Write a brief (1-2 sentence) description of what you think is wrong with the program. What is its output? How could the program be changed to produce a more correct result? Be specific; describe particular changes that would need to be made, or lines that would need to be altered or added to the program. If you like, you can include a rewritten version of the code that you believe will behave correctly, but this is not required.
Self-Check 4.4: logical expressions (p261). This problem asks you to convert English sentences into logical tests. For example the sentence, "x is a positive integer," could be converted into the logical test, x > 0
. Solve only the first, fifth, seventh, and twelfth bullets. These are the ones that begin as follows:
z
is odd.y
is a multiple of ...y
is greater in magnitude than ...x
is closer in value to y
than ... (Hint: Use the Math.abs
method to help find the difference between two numbers.)Write a logical expression for each of the above bullets. You do not need to show your work.
Self-Check 4.8: Divisible
(p262). Write a brief (1-2 sentence) description of what you think is wrong with the program. What are some cases where the code will behave incorrectly? How could the program be changed to produce a more correct result? Be specific; describe particular changes that would need to be made, or lines that would need to be altered or added to the program. If you like, you can include a rewritten version of the code that you believe will behave correctly, but this is not required.
Exercises: Solve the following one (1) Self-Check problem on paper and bring your sheet of paper to your section on Thursday:
Params1
(p166). Write the output of the program.
Show your work, such as by writing down what values are passed for each parameter to each call. Circle your final answer/output so it's clear which part is the answer vs. intermediate work.
for
loops
(Thu Oct 8)
Exercises: Solve the following two (2) Self-Check problems on paper and bring your sheet of paper to your section on Thursday:
2 + 3 *
... through (18 - 7) *
...
4.0 / 2 *
... through 12 / 7 *
...
Please show some work rather than just writing the answer. You could write out sub-expressions as you compute their values, or circle/underline operands to show precedence, etc. You may use a calculator if you want, though one shouldn't be necessary for these problems.
No problems are due for the first week's section.