Sections
Our sections are 50-minute discussions led by section leaders each week in which the SL and students work together to solve problems.
Week8 Sat 12:00 PM
Week 9 ( - ):
Section 8: Inheritance
Section 8 Handout
Section 8 Solutions
-
Correction: The solution to the
MinMaxAccount
problem in the printed handout had a typo.
The solution has been corrected in the online solutions document linked above.
No pre-section problem this week.
You will receive full section participation credit for this week if you just attend your section and take part in working on the problems.
Week7 Sat 12:00 PM
Week 8 ( - ):
Section 7: Graphical User Interfaces (GUIs)
Pre-section problem: Solve the following problem on paper (hand-written or printed) and bring your sheet of paper to your section.
This problem does not come from the textbook.
-
Write a graphical program that displays a text label with the text, "All WORK and no PLAY makes JACK a dull BOY."
(This quote comes from the classic movie, The Shining.)
Place the label in the northern area of the window.
Also add three buttons to the southern area of the window that have the following behavior:
- Lowercase: Converts the onscreen label to lowercase.
- Cool: Changes the word "dull" to "cool" in the label text, leaving the other text unchanged.
- Red: Makes the window's background color become red.
The following screenshots show the effects of these buttons.
Assume that you are starting from the given skeleton program.
Our own solution adds 14 total lines of code to the skeleton below:
one field, 6 lines in init
, and 7 lines in actionPerformed
.
(You can also download the code below if you want to type it in.)
public class Shining extends Program {
// fields
public void init() {
// TODO: implement
}
public void actionPerformed(ActionEvent event) {
// TODO: implement
}
}
-
section07-code.zip
(If you want to type it up, optionally. Make sure to bring a paper printed copy no matter what.)
Week6 Sat 12:00 PM
Week 7 ( - ):
Section 6: 2-D Arrays, Image Manipulation, HashMap
No pre-section problem this week:
Since you're busy this week studying for the midterm exam, there are no pre-section problems to do this week before your section.
You will receive full section participation credit for this week if you just attend your section and take part in working on the problems.
Week5 Sat 12:00 PM
Week 6 ( - ):
Section 5: ArrayList and Arrays
Pre-section problem: Solve the following book exercise problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- a variation of Exercise 11.2 (p451) - "In statistics, a collection of data values is ..."
The book exercise says to accept an array of double
as your parameter.
But instead, write a version that accepts an ArrayList
of double
s.
If the list is empty, your method should return 0.0
.
The book also says to test your method by incorporating it into a GymnasticsJudge
program; you don't need to do that.
If you want to test your code, download our ZIP file below.
-
section05-code.zip
(If you want to type it up, optionally. Make sure to bring a paper printed copy no matter what.)
Week4 Sat 12:00 PM
Week 5 ( - ):
Section 4: Strings, Characters, and File Processing
Pre-section problem: Solve the following book exercise problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Exercise 8.6 (p287) - "A palindrome is a word that ..."
Just write the method itself; you don't need to write the test program mentioned in the problem statement.
Consider any one-letter or empty string to be a palindrome.
If you want to extend the code to work for full sentences with spaces and punctuation as described in Exercise 8.7, feel free to do so, but that is optional.
-
section04-code.zip
(If you want to type it up, optionally. Make sure to bring a paper printed copy no matter what.)
Week3 Sat 12:00 PM
Week 4 ( - ):
Section 3: Parameters, Return, Animation, Fields
Pre-section problem: Solve the following book exercise problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Exercise 5.4 (p172) - "Write a method
countDigits(n)
that ..."
(See book Figure 4-6 for a helpful example to get you started.
Can you write a version that handles negative numbers?)
-
section03-code.zip
(If you want to type it up, optionally. Make sure to bring a paper printed copy no matter what.)
Week2 Sat 12:00 PM
Week 3 ( - ):
Section 2: Java Control Statements; Graphics
Pre-section problem: Solve the following book exercise problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- a variation of Exercise 4.4 (p128) - "Write a program that displays the integers between ..."
Write a variation of the book's exercise where you print all of the numbers in the range, separated by spaces.
Use a loop to print the numbers.
But for multiples of three print "Fizz" instead of the number, and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". The output would be:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz
Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58
59 FizzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76
77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz
Fizz 97 98 Fizz Buzz
("FizzBuzz" is a commonly known problem.
Many companies actually ask their interview candidates to solve it, and surprisingly a large number of applicants are unable to do so.
It's considered a good "weed-out" problem because anybody with a CS degree ought to know how to solve a problem like this.)
You can just write out the code by hand and make your best attempt to solve the problem.
If you want to actually code up the solution in Eclipse, you can do so using our starter project ZIP below, but you don't have to do so.
If you type it in, you'll need to print it out or rewrite it by hand so that you can turn it in on paper at your section; we do not accept it digitally such as by email.
If you like, you do not need to write a complete program; just the relevant lines of code to answer the question.
(See detailed information below about pre-section problems.)
Keep in mind that these pre-section problems are meant to be short warm-up drills to get you ready for section.
They are not meant to take a large amount of time or cause you undue stress.
If you're taking more than 15-20 minutes on this problem, you can stop and give your partial work to your SL and you will receive credit.
Week1 Sat 12:00 PM
Week 2 ( - ):
Section 1: Karel the Robot; Basic Java
Pre-section problem: Solve the following book exercise problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Review question 3.7 (p90) - "By applying the appropriate precedence rules, calculate the result of each of the following expressions: ..."
Solve all of parts a) - d).
Show your work by writing out each expression part that is evaluated in order.
For example:
1 + 2 * 3 + 4
-----
1 + 6 + 4
-------
7 + 4
----------
11
You can just write the answer(s) by hand and make your best attempt to solve them.
The "Section 1 Handout" problems from the PDF document above are the problems that you'll work on in your section this week with the section leader.
You don't need to work on any of those before your section, though you can optionally read them ahead of time if you like.
Week1 Mon 8:00 AM
Week 1 ( - ):
no section
We will not hold section during the first week of the quarter.
Sections begin during Week 2.
Pre-section problems:
Each week you will complete short problem(s) from the book to turn in at your section.
Completing these problems each week becomes part of your "participation" score which is part of your grade.
Another part of your "participation" score is 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.
If you want credit for doing the problems, you must bring the solutions on paper, not email them digitally to your SL.
Also, you must bring them yourself, not have a friend bring them for you.
Pre-section problem solutions are not accepted late.
Our intention is that these problems would take no more than 15-20 minutes each week.
If you find yourself taking significantly more than this, you may stop your work and write that you worked for 20 minutes.
If you have made significant progress, we will still give you credit for your work even if you did not finish the problem(s).
This document and its content are copyright © Marty Stepp, 2014.
All rights reserved.
Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the author's expressed written permission.