Schedule at a Glance (see archives
for older entries)
Written assignments should follow the HW guidelines.
|
|
W 1/20/16
D
|
First day of class.
|
|
Th
1/21/16
E
|
No class.
|
|
F 1/22/16
F
|
Snow day. The assignment
originally due today has been postponed until Monday. If Monday also turns
out to be a snow day, you will need to check this page for additional
assignments that will be due when school resumes.
|
|
M 1/25/16
G
|
Snow day.
However, the following HW assignment is still due today:
1. Send a test e-mail (double underscore required at beginning of subject
line) in which you identify yourself by name. See Mr.
Hansen’s contact information if you forgot to copy down the e-mail
address in class on Wednesday.
2. Download Version 5.1.2 of the online textbook in PDF format by clicking here. Make sure you
get the correct version.
3. Continue to monitor www.modd.net for additional assignments during the
snow days.
|
|
T 1/26/16
A
|
Snow day. However, there is
no additional assignment due until tomorrow, since IPL does not meet on A
days anyway.
|
|
W 1/27/16
B
|
HW due:
1. Make sure that you have completed all the assignments for Monday (see
above). The test e-mail requirement was eventually met (more or less) by everyone.
2. Read Chapter 1 (pp. 1-11) in the textbook that you downloaded.
Double-check to make sure you are working with Version 5.1.2 of the textbook,
not the draft of Version 6 that is still in progress. Reading notes are
required, as is always the case for all reading assignments this semester.
Click on the HW guidelines link (at the top of this schedule) for
instructions on the required formatting for all reading notes and other
written assignments.
3. Prepare for an open-notes quiz on Chapter 1. The terminology (defined in
the glossary at the end of each chapter) is especially important. You may not
use any computer-produced printouts during the quiz; only handwritten notes
are permitted. (Rationale: Educational research has shown that handwritten notes
are much more effective for learning than typed notes or copied-and-pasted
notes. The reason seems to have to do with the fact that when we make
handwritten notes, we are forced to summarize and rephrase what we have heard
or read, and the process of thinking about the material helps us to remember
it better. It is all too easy to take notes on a computer without ever
thinking about what we are doing. As one researcher from the University of
Virginia, Daniel T. Willingham, has said, “Memory
is the residue of thought.”)
|
|
Th
1/28/16
C
|
No additional HW due.
However, another open-notes quiz is possible.
|
|
F 1/29/16
D
|
HW due:
1. Read Chapter 2. Reading notes are required, as always.
2. Visit www.eclipse.org and attempt to download the Eclipse IDE and Java
environments for your laptop, if you have one. (Otherwise, you can use a
classroom PC.)
|
|
M 2/1/16
E
|
No class.
|
|
T 2/2/16
F
|
HW due:
1. Continue setting up Eclipse and the Java Runtime Engine set up on your
computer. Some platforms are much easier than others. If you cannot get yours
to work, you are welcome to use a classroom PC for your programming
exercises.
2. Convert the following integers from binary to decimal (base 10) and also
to hex (base 16). Remember that all hex values must be labeled with the 0x
prefix or the h suffix. Try to do all the work on your own. You may check
your answer with the Windows calculator program.
010010100110000101010000
11011010100110101010010101010101
1011010110101011010111010101101010111010
3. Convert the following hex integers to binary.
0xFACEB00C
0xF00ECABB
0x12345678ABCD
4. What is the largest possible dword hex value?
Give answer in hex.
|
|
W 2/3/16
G
|
HW due:
1. Use the ASCII table distributed in class (or find one online) to convert
the following 5 bytes of text to hex and then to binary:
STA#1
2. Convert the decimal
(base 10) integer 357,895,840,561 to hex and then to binary.
3. Suppose that computer forensic experts have uncovered the following sequence
of bits on a criminal’s hard drive:
0101001101010100010000010010001100110001
The prosecuting attorney says, “Aha! This proves that the owner is a St.
Albans Bulldog supporter!”
(a) As a defense attorney, what do you say in response?
(b) Glance at this article.
(Do not read the entire article! Just skim it quickly.) Then, state at least
3 possible meanings for the bit sequence
0101001101010100010000010010001100110001. With a little bit of thought, you
can come up with many more than 3 possibilities. How many can you think of?
|
|
Th
2/4/16
A
|
No class.
|
|
F 2/5/16
B
|
HW due:
1. Complete Exercises 1.1, 1.2, and 1.3, using either your laptop or one of
the lab computers. Be sure to record your results in writing for each
exercise, especially 1.3.
2. Complete Exercise 2.3 (all parts). Make sure that you intermingle the
printing of text and numbers so that the output of the program is
intelligible to a human. For example, if the number of seconds remaining in
the day is 50,345, the program should not output
50345
but rather something like this:
number of seconds remaining in the
day = 50345
Also, please have your source code
available for inspection, either as a printout or as something you can
display at a moment’s notice on your laptop when homework is checked.
In class: new vocabulary words abend,
pseudocode, rootkit.
|
|
M 2/8/16
C
|
HW due:
1. Clean up last week’s assignment so that it conforms to the HW guidelines.
For Exercise 2.3, a source code printout is acceptable. If you are able to
display your source code for Exercise 2.3 on a moment’s notice (e.g., on a
laptop), that is also acceptable.
2. Be sure that your source code for Exercise 2.3 includes at least one
comment. From now until the end of the semester, every program you write must
include at least one comment, and the following information is required at a
minimum: name of programmer, date of this version of the code, and purpose of
the code. If you want to be a little fancier, here is an example you are free
to copy and paste into your own code, with modifications:
/************************\
| |
| Time of day exercise |
| Version:
1.01 |
| Written by: M. Hansen |
| Date: 20160205 |
| Version:
1.01 |
| |
\************************/
This works, because slash-asterisk (/*) can be used in Java (as well as in C
and C++) to indicate the start of a comment block, and asterisk-slash (*/)
can be used to indicate the end of a comment block.
Fancy comments are not required, but every program must have at least one
comment in its source code, and every source code listing must include the
name of the programmer, the date, and the purpose of the program.
3. Every day, there are undoubtedly some tasks that you typically do between
dinner and the time you climb into bed to go to sleep. Make a flowchart for
your activities on a typical night between dinner and bedtime, and include at
least one example of each of the following features:
(a) Simple statements (rectangles)
(b) Method/subroutine calls (hexagons)
(c) Return statements (ovals)
(d) Start and Stop statements (ovals)
(e) Decision statements (diamonds)
(f) Input/output statements (parallelograms)
(g) Abend (oval)
Off-page connectors (pentagons shaped like a home plate) are not required,
but feel free to use them for style points. Some judicious simplification is
encouraged. For example, if you have a statement labeled “Floss teeth,” you
can omit the step of walking over to the wastebasket to throw away the used
dental floss.
4. Repeat exercise 3, your typical nighttime activities between dinner and
bedtime, except this time do it in pseudocode. To help you do this, an
example is provided below. You will recognize the example, since it is
equivalent to the flowchart we concocted in class last Friday. Remember,
there is only one hard-and-fast rule of pseudocode, and that is that the
steps must be clear to you. In other words, they must correspond to things
that you actually know how to do. (In computer science, each step in
pseudocode must correspond to something that a computer is capable of doing.)
Indentation, although there are no hard-and-fast rules, should follow common
sense and should help you understand the logical structure of your algorithm.
Comments are not required in pseudocode, but they can be helpful. Remember,
pseudocode is for you and is
supposed to help you keep track of
the logical flow.
The suggested indentation format is to indent whenever a higher-level idea is
in progress. For example, we indent the individual steps within any procedure
or method to help keep track of which method is in progress, and we indent
the contents of an “if” statement so that we know which “if” test is in
progress. The word “endif,” which is used in some
languages but not in Java, is recommended in order to clarify the extent of
each “if” statement. Note that multiple levels of indentation are possible.
For example, you can have an “if” nested within another “if” (or an “if”
within an “if” within a loop within another “if” within a subroutine and so
forth).
So, with all that out of the way, here is your pseudocode example:
Get-to-STA //how
to go from bed to Senior Circle
//by
Mr. Hansen and the Block 6 class (esp. Rashaun)
//version
0.01, 20160205
call
Morning-at-home
hop into car
call
Drive
hop out
say to Mom, "See ya
later."
end
Morning-at-home //subroutine (a.k.a.
method)
wake up
shower
brush teeth
dress
gather stuff for school
return
Drive //subroutine
watch Mom turn ignition key
if car fails to start
try again
if car still fails to start
telephone
AAA
telephone
Ms. Spaulding at STA (202-537-6412)
HALT //abend
endif
endif
back out of driveway
head E on Finnegan
turn R on Elm
turn L on 3rd St.
turn L on Wisconsin
turn L on Lych Gate
turn R on Church House
go straight to Senior Circle
return
|
|
T 2/9/16
D
|
HW due: Read Chapter 3.
Reading notes are required, as always.
|
|
W 2/10/16
E
|
No class.
|
|
Th
2/11/16
F
|
HW due: Write Exercises 3.2
(part 1 only) and 3.4 (all parts).
|
|
F 2/12/16
|
No school (faculty professional
day).
|
|
M 2/15/16
|
No school (holiday).
|
|
T 2/16/16
G
|
HW due:
1. Read Chapter 4. Reading notes are required, as always.
2. Write Exercise 4.5 after reading the notes below.
Notes:
1. In the first sentence of the exercise, change “there are no integers a, b,
and c such that” to “there are no
positive integers a, b, c,
and n such that.” The author of the
textbook is not a mathematician, apparently, and he simply stated the theorem
incorrectly.
2. Also in the first sentence of the exercise, change “except in the case
when n = 2” to “when n > 2.”
3. The final statement should now read as follows:
Fermat’s Last Theorem says that there are no integers a, b, c, and n such that an
+ bn
= cn
when n > 2.
4. The method raiseToPow actually already exists,
mostly. It is called Math.pow, and it works almost
exactly as you would expect. For example, Math.pow(2,
3) returns 8.0. The only wrinkle is that Math.pow
returns a double, and for the program in Exercise 4.5, you want an int to be returned. Well, that is easy to fix. Simply
typecast the return value from Math.pow as an int.
For example, if you want to raise 2 to the 3rd power and store the value into
an integer, you could simply use this line of code:
int i = (int)
Math.pow(2,3);
5. The output messages that
the problem asks for are not very good. Recommended wording for the case
where an + bn =
cn
and n > 2, which should never
occur, would be “Stop the presses! We have found a counterexample that disproves
Fermat’s Last Theorem!” The recommended wording for all other cases would be
“Your values for a, b, c, and n do not contradict Fermat’s Last Theorem.”
6. Test your method, called checkFermat, by calling
it multiple times from main with various values of a, b, c, and n. For
example, your main method could be something like this:
public
static void main(String[] args) {
checkFermat(3, 4, 5, 2);
checkFermat(3, 4, 5, 3);
checkFermat(3, 4, 7, 1);
checkFermat(3, 4, 6, 1);
checkFermat(1, 1, 2, 1);
checkFermat(1, 8, 9, 3);
}
|
|
W 2/17/16
A
|
No class.
|
|
Th
2/18/16
B
|
HW due:
1. Finish the assignment that was due Tuesday. If you need help, send an
e-mail with the following subject line (replace Jane Smith with your actual
name, last name first, first name last):
__Specific
questions for assignment due 20160216 [Smith, Jane]
When you are finished, e-mail the source code for your checkFermat
method using the following subject line:
__Source
code for assignment due 20160216 [Smith, Jane]
The source code must be pasted as text into the body of your e-mail message.
Source code sent as a file attachment will be discarded. Remember, your
source code must include comment(s) that, at a minimum, give your name, the
date, and the purpose of the code. If the work is not entirely your own, you
must add comments to document any help that you received.
2. Write a detailed set of requirements for the problem described herein. You
will be provided with a main method, as listed below. The output should be 3
lines of “true” and 3 lines of “false” when you complete the program
correctly. Your program, when completed properly, should check whether 3
integers constitute a Pythagorean triple. For this problem, you may assume
that the integers are always provided in descending order. You should have
learned what a Pythagorean triple is when you took geometry, but if you have
forgotten, you can look up the term “Pythagorean triple” on Wikipedia.
3. Complete the program described in #2. If you would like to see if your
requirements are acceptable, you may e-mail them using the following subject
line (replace Jane Smith with your actual name):
__Detailed
requirements for assignment due 20160218 [Smith, Jane]
When you are finished, e-mail the source code for your checkTriple
method using the following subject line:
__Source
code for assignment due 20160218 [Smith, Jane]
The source code must be pasted as text into the body of your e-mail message.
Source code sent as a file attachment will be discarded. Remember, your
source code must include comment(s) that, at a minimum, give your name, the
date, and the purpose of the code. If the work is not entirely your own, you
must add comments to document any help that you received.
If you are happy with your requirements, you can leave them in
pencil-and-paper form and show them in class.
Here is the main method you should use for testing:
public
static void main(String[] args) {
checkTriple(5, 4, 3);
checkTriple(10, 8, 6);
checkTriple(13, 12, 5);
checkTriple(6, 4, 3);
checkTriple(10, 8, 7);
checkTriple(1752, 152, 15);
}
|
|
F 2/19/16
C
|
HW due:
1. Read Chapter 6 (pp. 55-68).
2. Do Exercise 6.2 on p. 69, all parts.
Hint for parts 4 and 5: Add this
line to the start of your main method:
double
pi = Math.asin(1)*2.0; // computes pi
Or, better yet, simply use Math.PI whenever you
need the value of pi. (Math.PI is a constant that
can be used anywhere, provided you have access to the Math class.) Then,
assuming your multAdd method is correct, you can
perform an action like the first one in part 4 by doing this:
System.out.println(multAdd(Math.cos(Math.PI/4),0.5,Math.sin(Math.PI/4)));
If you have a variable (double pi), your code becomes slightly shorter but
also slightly less robust:
System.out.println(multAdd(Math.cos(pi/4),0.5,Math.sin(pi/4)));
The other multAdd challenges are a little bit
harder, but you are free to perform online research if necessary. Freshmen
(who have not seen logarithms yet) and others who are shaky on their log
properties should note that log 20 = log(2 · 10) = log 2 + log 10. Therefore,
if you do a little bit of algebra, log 10 + log 20 can be rewritten in the
form a*b+c, which is what we need for the multAdd method. The function Math.log(x) will return a
double that equals the log of x, provided x>0. The other functions you
need are Math.sqrt(x), which returns the square
root of x, and Math.exp(x), which returns ex. (The number e, as everyone except freshmen should
already know, is approximately 2.71828.)
|
|
M 2/22/16
D
|
HW due: Do Exercise 6.5,
except that in addition to writing the distance method, you should also write
the sumSquares and main methods. Try to do these on
your own, but if you cannot, you may use code similar to that shown below.
(No fair peeking until you have tried on your own!)
public
static void main(String[] args) {
System.out.println(distance(1,1,2,2));
}
public static double sumSquares(double
a, double b) {
return a*a + b*b;
}
|
|
T 2/23/16
E
|
No class.
|
|
W 2/24/16
F
|
HW due:
1. Work to finish and submit all of the previously assigned programs (due
2/16, 2/18, 2/19, and 2/22). Use the following subject lines, changing
“Smith, Jane” to your own name, last name first:
__Source
code for assignment due 20160216 [Smith, Jane]
__Source
code for assignment due 20160218 [Smith, Jane]
__Source
code for assignment due 20160219 [Smith, Jane]
__Source
code for assignment due 20160222 [Smith, Jane]
Remember, these are individual
homework grades. The homework tote board shows
that most people are deficient in one or more of these programs.
2. Start working with your partner on the detailed requirements (and some
preliminary source code, if you wish) for the dayOfWeek
method, which you will eventually test by using a main method resembling the
following:
public
static void main(String[] args) {
System.out.println(dayOfWeek(12, 1, 1999);
System.out.println(dayOfWeek(2, 22, 2016);
// etc.
}
Your dayOfWeek method should accept 3 ints for month, day, and year, and it should degrade
gracefully if the date is illegal (e.g., February 31) or outside the domain
of March 1, 1900, through December 31, 2099. Use the algorithm described in
class on Monday, 2/22/2016, with month codes of 0336 1462 5035.
Hint: If your detailed requirements
are correct, your source code will probably be easy to write, and your source
code may even be nearly bug-free on the first try. However, if your detailed
requirements are incorrect, you have no hope of producing a program that
works correctly.
You can write your detailed requirements in English and/or pseudocode.
However, the essential ingredient is clarity.
You have to understand exactly what the dayOfWeek
method is supposed to do and how it is supposed to do it.
|
|
Th
2/25/16
G
|
HW due: Continue working
with your partner on the dayOfWeek assignment. Make
sure to satisfy the detailed
requirements that we produced as a group.
|
|
F 2/26/16
A
|
No class.
|
|
M 2/29/16
B
|
HW due: Continue working
with your partner on the dayOfWeek assignment. You
should be shooting for completion by tomorrow (Tuesday).
In class: Decibels (dB).
|
|
T 3/1/16
C
|
HW due: By the end of the
day, submit your dayOfWeek code (dayOfWeek method and all supporting methods) by e-mail.
Use the following subject line, changing group number and names as needed.
__Source
code for assignment due 20160301 [Group 9, Smith/Zimmerman]
Here are the group numbers and team members:
Group 1: Nicole and Jose
Group 2: Kwaku and Chris
Group 3: Alex and Luca
Group 4: Elizabeth and Adam
Group 5: Ly-Lan and Rashaun
Group 6: Jordan and Katie
Group 7: Kevin and Alan
Group 8: Henry and Will
Please make only one submission per group. If your code meets requirements,
you will probably not receive any comments in reply. If there is a problem
that the automated test procedure detects, you will not receive the full
number of points possible. Please test your code thoroughly before you submit
it!
If you need more time, please submit your request by e-mail, including the
estimated amount of additional time you need and the reason for your request.
Use a subject line similar in this format:
__Request
for extension beyond 20160301 [Group 9, Smith/Zimmerman]
|
|
W 3/2/16
D
|
HW due:
1. Try to wrap up your dayOfWeek code. See previous
day’s entry for instructions.
2. Read Chapter 7 (pp. 75-86). Reading notes are required, as always.
In class: Looping (iteration) as contrasted with recursion.
|
|
Th
3/3/16
E
|
No class.
|
|
F 3/4/16
F
|
HW due:
1. Write Exercise 7.1 (p. 87).
2. Redo Exercise 7.1 with the modification that the final non-squiggly line
of code is changed from
i = i + 1
to
i = i – 1.
3. Describe, in English, what the modified
version of Exercise 7.1 is doing. Hint:
You may want to test a dozen or so numbers up to, say, 1000.
|
|
M 3/7/16
G
|
HW due:
1. Write a void method called countBy that accepts
two ints and uses a while loop. The first parameter should be positive and
should tell what multiples to count by. The second parameter should be
positive and should tell how many lines to print. For example, if we make a
call to countBy(7, 4), the countBy
method should count by 7 a total of 4 times, producing the following output:
7
14
21
28
2. Repeat the first exercise, except this time, write a method called countByRevised. The requirements are identical to those
for the countBy method, except that you are to use
a for loop instead of a while loop. Use the syntax for the for loop that was given in class on Wednesday, 3/2, or
if you prefer, you can look ahead in your textbook to see examples of for loops in action.
3. For both methods (countBy and countByRevised), do not send your source code by e-mail
this time (unless you are stuck and need help). Instead, test both methods
and then write them out, neatly, on your HW paper. Both methods are extremely
short, so this is a fair request. In class, we will swap papers and will
conduct code review of each others’ methods. As
always, be sure to include comment lines in your code that satisfy the
minimal requirements of name, date, and purpose.
|
|
T 3/8/16
A
|
No class.
|
|
W 3/9/16
B
|
HW due:
1. Refactor your code for countBy and countByRevised (showing changes in a different color of
ink) to make your code easier to read
and more robust. “Easier to read”
means that you should use some of the ideas discussed in class on Monday
(e.g., self-descriptive variable names, names that respect the recommended camelCase naming convention, loop counters that go from 1
through the number of lines to print, and meaningful but not redundant
comments). For example, if you increment lineCtr
using a line of code like this:
lineCtr++;
then there is no need to write a comment saying that you are incrementing the
line counter. Any Java programmer could see that instantly. However, remember
that any variable whose purpose is not obvious from its name should be
commented.
“More robust” means that you should check for some reasonably foreseeable
error conditions. The first parameter does not need to be positive, but the
second one certainly does. The second one should be limited in size to some
reasonable value that you determine.
If your original countBy or countByRevised
code was not running correctly, you may want to start over, and that is
permitted.
2. Just as we can have nested if statements,
we can have nested for loops. Write
nested loops (for loops are
strongly recommended) to meet the following requirements:
(a) The void method printElementIndices
should accept 3 parameters.
(b) The first parameter shall be a boolean, where true indicates a hypothetical matrix whose first element
is labeled (0,0), and false indicates
a hypothetical matrix whose first element is labeled (1,1). We call a
rectangular matrix whose first element is labeled (0,0) a “zero-based”
matrix. The zero-based style is common in computer science, but in most math
classes, the element in the upper left corner of the array is called (1,1),
not (0,0).
(c) The second parameter is to be a positive
integer, less than or equal to 9, indicating the number of rows in a
hypothetical matrix.
(d) The third and final parameter is to be a
positive integer, less than or equal to 9, indicating the number of columns
in a hypothetical matrix.
(e) The purpose of the printElementIndices
is simply to print the element names of a hypothetical matrix of the given
size. In other words, it is supposed to educate students who may have trouble
naming the elements of a matrix. For example, printElementIndices(false,
3, 2) should print the following element names in a format of 3 rows by 2 columns:
11
12
21 22
31 32
Students sometimes have trouble learning how to refer to the elements of a
matrix. For example, a student may refer to the “two, three” element when
what he or she really means is the “three, two” element. This printout helps
to clarify where each element is located, and obviously, the “three, two”
element is located in row 3, column 2.
As another example, printElementIndices(true, 4, 9)
should produce the following output:
00
01 02 03 04 05 06 07 08
10 11 12 13 14 15 16 17 18
20 21 22 23 24 25 26 27 28
30 31 32 33 34 35 36 37 38
As you can see, this is a zero-based matrix having 4 rows and 9 columns,
exactly as requested.
|
|
Th
3/10/16
C
|
HW due: Finish your printElementIndices
code from yesterday. Remember, you were allowed to take the code given below
as a starting point:
public
static void printElementIndices(boolean zeroBased, int numRows, int numCols) {
for
(int
i=1;i<=numRows;i++) {
for
(int
j=1;j<=numCols;j++) {
System.out.print(i);
System.out.print(j+"
");
}
System.out.println();
}
}
All you have to add are two “bells and whistles”: (1) Print an error message
for any request in which numRows or numCols is negative or greater than 9, and (2) handle the
zeroBased flag.
When time ran out yesterday, quite a few people had produced code that
satisfied part (2) in the previous paragraph by doing something like this:
public
static void printElementIndices(boolean zeroBased, int numRows, int numCols) {
if (zeroBased) {
for
(int
i=1;i<=numRows;i++) {
for
(int
j=1;j<=numCols;j++) {
System.out.print(i);
System.out.print(j+"
");
}
System.out.println(); //advance
to next line before starting new row
}
}
else {
for (int i=0; i<=numRows-1; i++) {
for
(int
j=0; j<=numCols-1; j++) {
System.out.print(i);
System.out.print(j+"
");
}
System.out.println(); //advance
to next line before starting new row
}
}
}
However, this approach is considered undesirable because it duplicates code.
That’s potentially a problem. Why? Well, if at some later time, you
discovered a bug or wanted to make a general enhancement to the printing
format, you would have to remember to change both blocks of code. Forgetting to change all the places that
need to be changed is an excellent way of producing bugs. Thus, there is this
general principle of programming: Try
to avoid duplicating code.
There are many ways to address this issue. One is to initialize an int variable called zeroBasedAdjustment
at the start of the method. Then, set zeroBasedAdjustment
equal to 1 if zeroBased is true, 0 otherwise. Your
loop control statements can then be modified slightly; just remember to
subtract zeroBasedAdjustment when coding your
loops. Do you see that the only difference between the two blocks of code
above is that the loop control statements are adjusted downward by 1 in the
second block?
Reducing code size is usually a good idea, but not always. You don’t want to
sacrifice readability simply to make a slightly smaller program. However,
when you can avoid duplicating code, a minor adjustment (such as zeroBasedAdjustment in this case) is usually worth
making.
Do not submit your code by e-mail. Instead, use pencil and paper to write out
a single submission for each pair, showing all indentation clearly and
correctly. The scribe for each pair should be the person with the worse
handwriting, since clearly that person needs more practice. The AP exam,
which many of you will be taking in 14 months, is still conducted 100% in
pencil and paper, believe it or not. Therefore, you have to practice
handwriting as a skill.
Your code will be scored on neatness (e.g., proper indentation) as well as
your ability to meet the requirements of the programming assignment. Pairs
will receive the same score unless there is evidence that the work was
distributed in a grossly unfair way.
|
|
F 3/11/16
D
|
No additional HW due. Please finish all requirements
for your printElementIndices method if you have not
already done so.
In class: Review, including the following quick coding challenge:
Requirements:
1. Assume that isPrime(int n) exists as a boolean
method.
2. Using the isPrime
method (which you should NOT write today) as a building block, write a main
method that prints the prime integers from 2 through 3000.
public
static void main (String[] args) {
//
Authors: Mr. Hansen and the IPL class
//
20160311
//
prime number illustrative example
for
(int i=2; i<=3000; i++)
{
if(isPrime(i)) {
System.out.println(i);
}
}
}
|
|
M 3/14/16
E
|
Pi Day (no class).
|
|
T 3/15/16
F
|
Test (Ver.
1.0) on all material covered to this point.
Study guide:
1. Know all the terms defined in the glossaries at the ends of Chapters 1-4,
6, and 7. Omit Chapter 5. You also need to know the terms that were discussed
in class but not in the text: pattern, antipattern,
beta test, 1GL, 2GL, 3GL, requirements creep, etc.
2. Recall and identify all the names we learned: Charles Babbage, Lady Ada
Lovelace, Alan Turing, Grace Murray Hopper, Bill Gates, Steve Jobs. You
should be able to recognize and/or provide a one-sentence synopsis of each
person’s contribution to computer science. Optional: Mark Zbikowski.
3. Make sure you can write a main method from memory: public static void main
(String[] args) { }.
4. Know the purpose of int, double, and boolean declarations and how to use them in a program.
5. Be able to write a void method as well as a method that returns a value.
6. Be able to call methods you have written as well as methods (such as isPrime from last Friday’s class) that are merely
described for you.
7. Be able to write for loops, while loops, and loops within loops if necessary.
8. (Optional.) To see if you really know what you’re doing, code the isPrime method that we discussed (but did not actually
program) last Friday. The requirements are as follows:
(a) The isPrime method must accept an int (henceforth denoted as n) and must return a boolean.
(b) Integers less than 2 are to be considered nonprime by definition. Return false if this is the case.
(c) Assuming that n is 2 or more, n is to be initially considered prime
by default. Use a boolean scratch variable
initialized to true for this
purpose. We will change that value to false if a divisor is found later.
(d) For all potential divisors from 2 through n – 1, see if n divides
evenly.* (If the potential divisor is called potentialDivisor,
all we need to check is whether n %
potentialDivisor == 0.)
(e) If any potential divisor is found to work, return false; otherwise, when the loop is finished, return the
default value of the scratch variable, namely true.
* This algorithm works, but it is wasteful. Most programming textbooks will
say that you should end the loop at Math.sqrt(n) in order to make the code run
faster. The reason that ending at Math.sqrt(n) works is that divisors always occur
in pairs, with one in the set of integers from 2 through Math.sqrt(n) and the other in the set from Math.sqrt(n)
through n – 1. Therefore, it is a
waste of time to check both sets of integers; we need only check the set from
2 through Math.sqrt(n).
Note, however, that the loop must go at least through Math.sqrt(n), since otherwise we would stop too
early to catch all possible divisors. For example, 289 is nonprime, since 289
= 172. The divisor of 17 will be detected only if the loop that
searches for possible divisors goes through
the square root of n, namely 17 in
this case.
Bottom line: For now, it is entirely acceptable to code the loop as
for (int potentialDivisor=2; potentialDivisor <= n-1; potentialDivisor++)
{
// other code goes here
}
in order to keep things simple.
|
|
W 3/16/16
G
|
Test (Ver.
2.0) on all material covered to this point.
The test will be similar in difficulty to the test you took yesterday. Both
tests will be scored, and the higher of the two scores will be used in your
quarter grade average.
|
|
Th
3/17/16
A
|
No class.
|
|
F 3/18/16
B
|
Last day of Q3.
HW due: Read Chapter 8 (pp. 91-100). Reading notes are required, as always.
|
|
Spring Break
|
Mr. Hansen has to compute grades and submit them to
the STA and NCS registrars during spring break. Please immediately check the homework tote board to make sure that you have
received credit for all assignments that you thought you submitted. A total
of 26 individual assignments and 2 dayOfWeek pairs
assignments were not submitted by the formal end of the quarter on 3/18. If
you do not reply by 11:59 p.m. EDT on Tuesday, March 22, it will be assumed
that you accept the tote board as it is.
|
|
M 4/4/16
C
|
Classes resume.
In class: We learned how changing a single line of code can sometimes make a
huge difference in runtime. (Nevertheless, most speed optimizations nowadays
are not worth doing, since the user, not the computer, is usually the
bottleneck.) We learned that NCS trounced STA in all four grading categories
in Q3 (HW, quizzes, tests, and graded projects). We learned how to execute
the simple HOTPO algorithm (halve the integer if it’s even, otherwise triple
it plus one). And most important, we listed most of the unstated “stealth” requirements that accompany all
3GL programming projects you will ever write:
- Some comments are required (at minimum, name, date, and purpose).
- Indentation must be helpful. Absolute consistency, while a desirable goal,
is not a requirement.
- Use camelCase for variable names [and upper case
for class names].
- Variable names should be self-descriptive, or well-commented if it is not
practical to make them self-descriptive.
- Program should degrade gracefully to the extent possible: Check all inputs!
- Test your code (unit testing, end-to-end testing, regression testing,
alpha/beta/acceptance testing, etc.).
- No dead code.
- No repeated code. [Within reason, that is. Not every repetition of two
lines of code needs to be made into a method.]
- Spell check all output that will be seen by the user.
- Comments are permitted to be a bit sloppy. However, they must be helpful and up to date.
- Check for language-specific pitfalls. (Tip of the hat to Ly-Lan for
pointing that one out.)
|
|
T 4/5/16
D
|
HW due: Write pseudocode for the HOTPO chain-length
calculator. Do not code this in Java just yet. If you prefer to write a
flowchart instead of pseudocode, that is also acceptable.
Explicit requirement: Calculate, for any integer n > 0, the number of steps needed to reach 1 via HOTPO.
|
|
W 4/6/16
E
|
No class.
|
|
Th
4/7/16
F
|
HW due:
1. Read Chapter 12 (pp. 149-158). Reading notes are required, as always. This
is the last chapter that we will cover in Java before switching to Python
next week.
2. Write Exercise 8.1 (p. 100). You should test your code on a real compiler,
but your homework requirement is to handwrite
your code (don’t worry; it’s short) on your HW paper so that it can be handed
in if necessary.
3. Code the countHOTPO method in Java. You can and
should use pseudocode similar to what we hashed out in class (see below), but
remember that the “stealth requirements” (of which some are listed in the 4/4
calendar entry) are still in effect. You will, of course, need a main method
in order to test your countHOTPO method. Do not
e-mail your code just yet, but bring a hard-copy source code listing to
class.
Challenge (optional): After you
have countHOTPO running correctly, maybe you would
like to invest a few more minutes to write the “table” app that we discussed,
which would build a table of your countHOTPO
values, something like this:

Here is the pseudocode we developed in class on Tuesday, 4/5 (note the
addition of “endif” statements to help clarify
where the if-blocks end):
countHOTPO int method
that takes an int [namely, n]
if n < 1
error msg. and
return
else
counter = 0
while n 1
if
n%2 == 0
n/=
2
else
n
= 3n + 1
endif
counter++
wend
return counter
endif
end countHOTPO
|
|
F 4/8/16
G
|
HW due:
1. Finish your countHOTPO method and test it with
an input value of n = 21700. (The
result should be 162.) E-mail the source code for countHOTPO
(method only, no main method) by using a message line in this format:
__Source
code for assignment due 20160407 [Smith, Jane]
2. Write a main method that calls countHOTPO for
all multiples of 5 between 21400 and 21700, inclusive, counting the number of
times that 162 occurs as an answer. (You know that there must be at least
one, since countHOTPO(21700) equals 162.) Output
should resemble the following:
(#
of integers from 21400 through 21700 with HOTPO count of 162) = 14
Note: The correct answer is not 14.
The line above is meant only as an illustration of the output format to use.
E-mail the source code for your main method only (not countHOTPO) by using a message line
in this format:
__Source
code for assignment due 20160408 [Smith, Jane]
This assignment will be scored independently of your work for countHOTPO. Don’t worry if you still have bugs in countHOTPO itself. The scoring of your main method will be
based on how well it runs on a generic countHOTPO
that you didn’t even write.
|
|
M 4/11/16
A
|
No class.
|
|
T 4/12/16
X
|
Diversity Forum (no class).
|
|
W 4/13/16
B
|
HW due:
Add the following line of code at the beginning of your main method:
int[] hotpoVal = new int[201];
This creates an array called hotpoVal, containing
201 elements. Each element occupies 4 bytes of RAM, and the elements can be
referred to as hotpoVal[0], hotpoVal[1],
hotpoVal[2], etc., all the way through hotpoVal[200]. That makes 201 values in all. That’s a lot
easier than declaring 201 separate variables, each with its own name, isn’t
it?
(Please say yes.)
Create a main method that meets the following requirements:
1. The first line of code should be as given above. Please comment the line
with its purpose, which is to create an array of 201 elements that can store
HOTPO counts.
2. For the integers 1 through 200, inclusive, call the countHOTPO
method you wrote last week. Store each result into a suitable position in the
array. The recommended correspondence would be to put countHOTPO(1)
into hotpoVal[1], countHOTPO(2)
into hotpoVal[2], etc. However, you could also put countHOTPO(1) into hotpoVal[0],
countHOTPO(2) into hotpoVal[1],
etc., though why you would want to do such a thing is hard to fathom.
Sometimes it makes sense simply to waste the zero-th
element of an array, because it makes the code simpler to understand.
3. Compute the mean HOTPO count for the 200 integers from 1 through 200,
inclusive.
4. Use the patterns we learned last Friday for min- and max-finding to find
not only the minimum and maximum HOTPO counts (over the domain of inputs from
1 through 200, inclusive) but also all
positions at which the minimum and maximum values occur. Note that this may
require you to code more than one loop.
5. Output should resemble the following (but note that the statistics have
been intentionally falsified here):
On
the domain 1 <= n <= 200, we have these HOTPO statistics:
mean = 87.2367449
min = 5
Minimum occurs at
the following value(s) of n:
3
20
21
28
max = 106
Maximum occurs at
the following value(s) of n:
188
189
190
If you get stuck and need help, try working with a classmate. If that fails,
send e-mail with a subject line similar to this:
__Specific
questions for assignment due 20160413 [Clark, Bill]
When your code is debugged and fully meets requirements, send the main method
only (not countHOTPO) using a subject line similar
to this:
__Source
code for assignment due 20160413 [Clark, Bill]
|
|
Th 4
/14/16
C
|
HW due:
if
you have finished your assignment due yesterday
double-check code for clarity and completeness
double-check output to be sure it meets requirements
if (# of bugs or problems != 0)
send revised
version to Mr. Hansen
// Use same
subject line as before. Latest time-
// stamp will
indicate the version to be graded.
endif
get a good night's sleep
else
continue working on yesterday’s assignment
while (# of unresolvable questions != 0)
send e-mail to
Mr. Hansen
wend
finish your program
double-check output to be sure it meets
requirements
e-mail source code to Mr. Hansen
endif
|
|
F 4/15/16
D
|
HW due: Continue working on
your code that uses an array of HOTPO values (namely, the hotpoVal
array of ints) to compute mean, min, and max
statistics for the first 200 HOTPO results.
In class: Caching (multiple types) in real life as well as computers,
hard-disk drives, SDD technology, price improvements over the past decades,
files, sectors, clusters, metadata, “.” and “..” entries, path separator
characters, and the DIR command in the Windows command shell. Note that in
Unix-type systems (basically the rest of the world other than Windows), we do
not use the DIR command; we use the command
ls
or
ls
-la
instead
|
|
M 4/18/16
E
|
No class. If you have not
already submitted your code, get it in! Send e-mail if you are stuck, or ask
a classmate for suggestions. You may not copy lines of code, but
collaboration is acceptable. Use the subject lines found in the 4/13 calendar
entry.
|
|
T 4/19/16
F
|
HW due:
1. Download the Python textbook by clicking this link
and using the “File / Save as . . .” command to save a copy to your
computer’s hard disk
2. Read Chapters 1 and 2 (pp. 1-14) of your new Python textbook. Reading
notes are required, as always. Much of the information, especially concerning
natural and formal languages, plus syntax, runtime, and semantic errors, is
the same that you saw in the Java textbook. As a result, this reading
assignment should go quickly for you. But . . . be sure that you do the reading!
(Hint, hint.)
3. (Optional, but recommended.) Visit this link so that you can set up a
free account for a working Python environment in the cloud. Note: You must be 18 in order to set
up the account, because people under 18 cannot enter into legally binding
contracts. If you are not 18, ask one of your parents if he or she will serve
as the accountholder for an account that you can use.
|
|
W 4/20/16
G
|
HW due: Practice the Excelcise steps. You will eventually have to execute
all the steps in 5 minutes, and to do that, your skills will need to be
sharp. Note: Not all instructions
are shown on the sheet. You are expected to know certain standard tricks,
such as Shift+arrow key for selecting cells and Ctrl+B for bold.
|
|
Th
4/21/16
A
|
No class.
|
|
F 4/22/16
B
|
HW due:
1. Read Chapter 3 (pp. 17-26) of your new Python textbook. Reading notes are
required, as always.
2. Write Exercise 3.3, except with the following twist: Your function should
be named gridMaker and should accept an integer
argument between 1 and 4, inclusive. The value passed to gridMaker
specifies the size of the grid. For example, the output for gridMaker(1) would be a simple square, the output for gridMaker(2) should be as shown in the illustration on p.
27, and the output for gridMaker(4) would be the
same as the output of Exercise 3.3, part 2.
3. Continue practicing your Excelcise. We will have
our first timed run in class today. Some people may pass on the first try!
(Don’t worry if you don’t pass. Everyone must pass, eventually.)
|
|
M 4/25/16
|
No school (Phi Beta Kappa
Day).
|
|
T 4/26/16
C
|
HW due:
1. Continue practicing your Excel skills.
2. Continue working on your gridMaker function in
Python. If you feel more comfortable writing it in Java first and translating
it later into Python, that is certainly acceptable. By today (Tuesday), you
should either have fully working code or something quite close. Collaboration
with classmates is encouraged as long as you do not copy code.
3. The students listed below are behind in homework project submissions.
Assignment due 20160407: Jordan
Assignment due 20160408: Jordan
Assignment due 20160413: Adam, Chris, Jordan, Jose, Rashaun
Assignments not received by Tuesday afternoon will be treated as zeros for
the sake of midterm grade estimation, and since we have not had any tests yet
this quarter, a zero on a programming project would give you a failing grade.
Please submit your projects as soon as you can.
|
|
W 4/27/16
|
HW due:
1. Practice your Excel skills. There will be one additional opportunity to
take the Excelcise for credit during class today.
The time limit is 5 minutes. If you do not pass today, you will need to come
in after school, during a flex period, or during Block 5 to pass the Excelcise on your own time. Everyone must eventually
pass.
2. After the disappointing results of yesterday, we are realigning the gridMaker assignment as follows:
(a) Write out your detailed design, in
pencil. Pseudocode is fine, but a flowchart is also fine. You should not
begin coding until your design is clean. (This makes sense, since if you
can’t describe your steps in a flexible world where syntax rules do not
apply, how on earth will you be able to describe your steps in the nitpicky
world of Java or Python?) Your design will be collected and graded at the
beginning of class.
(b) After you feel that your design is reasonably good, code your gridMaker method in Java and test it. Note: It is strongly recommended that
you create a method for making the line that has a mixture of + and – signs,
since you can get lots of mileage out of that method. You call it once at the
beginning as well as once at the end of every additional block of 5 lines.
(c) (Optional.) If you get your Java code working well, go ahead and
translate it, line by line, into Python. This is difficult, because the
syntax is different, especially for print and println.
The System.out.print("mystring") command in Java becomes this in Python:
print('mystring', end=' ')
Luckily, the System.out.println command in Java
translates more easily into Python. (Java’s System.out.println()
command is essentially the same as Python’s print() command.) Remember to include
Python print statements at various points to terminate the line in progress.
|
|
Th
4/28/16
E
|
No class.
|
|
F 4/29/16
F
|
HW due: Get caught up on
all previously assigned work: textbook reading, programming projects, Excelcise practice, etc.
|
|
M 5/2/16
G
|
HW due: By 3:00 p.m. EDT
today, submit your gridMaker source code in Python.
Use the following subject line in your e-mail:
__Source
code for assignment due 20160502 [Smith, Jane]
If you are not yet finished, submit what you do have (even if it is only in Java, or even if all you have is a
pseudocode design), using the following subject line:
__Source
code (partial) for assignment due 20160502 [Smith, Jane]
Your source code for gridMaker will be accepted for
full credit through tomorrow, but only if you submit at least something by
3:00 p.m. EDT today. If you submit nothing, your score for gridMaker will be a zero.
|
|
T 5/3/16
A
|
No class. However, today at
3:00 p.m. EDT is the deadline for submission of gridMaker
source code in Python. See yesterday’s calendar entry for details.
|
|
W 5/4/16
B
|
HW due: Read Chapter 5 (pp.
39-47) of your Python textbook. Reading notes are required, as always.
In class: Quizzes on loops (in Java and Python) and Python
notation/terminology.
|
|
Th
5/5/16
C
|
HW due: Read Chapter 6 (pp.
51-60) of your Python textbook. Reading notes are required, as always.
In class: Guest speaker, Mr. Desmond Bowe, STA ’01. Mr. Bowe is a
professional developer and tech conference impresario with experience in
Objective-C, JavaScript, Swift, Ruby, etc. Bring your questions about coding,
project management, entrepreneurialism, and anything else you can think of!
|
|
F 5/6/16
D
|
HW due: Read Chapter 7 (pp.
63-69) of your Python textbook. Reading notes are required, as always.
|
|
M 5/9/16
E
|
No class.
|
|
T 5/10/16
F
|
HW due:
1. Read Chapter 8 (pp. 71-79) of your Python textbook. Reading notes are
required, as always.
2. Write Exercises 8.3 and 8.4 on pp. 79-80. Complete sentences are expected
for Exercise 8.4.
|
|
W 5/11/16
G
|
Field Trip.
Depart STA (bus on service road near Martin Gym) shortly after 8:00 a.m.
Regular school dress is required. We will be back by 1:00 p.m., in time for
lunch and our regular class period.
HW due at start of regular class period: Redo Exercise 8.4 on p. 80, except
this time, follow the alternate instructions below.
1. For each of the 5 proposed code blocks, write down what you conjecture the
behavior will be. For example, we conjectured in class yesterday that for
code block 1 (i.e., the any_lowercase1 function), the function would return
True if the first character in the input string is lowercase, False in all
other situations. (Note: This is a
slightly incorrect conjecture, but you are welcome to use it as a starting
point. It is not important that your initial conjecture be correct. What
matters is that you are willing to make
a conjecture and then apply test data as a way of learning.)
2. After you have written down all 5 conjectures, complete a table like the
following:

Be creative with your test data; do not restrict yourself to the 4 test cases
shown here. Note that the behavior of the function when the input string is
null should always be tested.
Note: When designing your test
cases, remember that you generally learn more from test cases (such as null
strings) that are trying to cause failure than you do from test cases that
are merely confirming what you already believe to be true. Make sure to
include attempted failures as well as attempted successes in your test data.
In order to fill in your table, you will need to compile all 5 code blocks.
Then, feed Python your test cases one by one, using a line of Python code
similar to this:
print(any_lowercase2("abc"))
Record what you learn in the table, using the comment field as suggested in
the example above.
|
|
Th
5/12/16
A
|
No class.
|
|
F 5/13/16
B
|
HW due:
1. Finish your testing table (see 5/11 calendar entry) for all 5 versions of
the function, any_lowercase1 through any_lowercase5. This table will be
collected.
2. Begin working on your Python version of the dayOfWeek
function. The requirements are the same as before, and your partner (unless
you request a change) will be the same as before.
Some groups misunderstood the requirements in the Java version. Just to be
clear, the dayOfWeek function is to return a string
in all cases. If the date is valid, the string returned will be one of the
following:
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
If the date is invalid, the requirement that the function must degrade
gracefully means that a string that is clearly different from one of the
valid outputs should be returned. A good practice would be to use a uniform
style for all your error messages. For example, you could start all of them
with a highly identifiable string such as
ERROR: Failure code ___ [description].
That would allow whatever code calls dayOfWeek to
easily determine whether an error had occurred.
For full credit, your program must conform to the full set of detailed requirements
that we produced as a class in February.
|
|
M 5/16/16
C
|
Field Trip (alternate date). Depart STA (bus on service road near Martin Gym) at
8:00 a.m. Regular school dress is required. We will be back by 1:00 p.m., in
time for lunch and your regular Block 1 class.
Anyone not going on this field trip (including anyone who went on the
previous field trip) should report to MH-102 at the usual time to sign the
attendance sheet and should then spend the class period working on dayOfWeek (Python version).
|
|
T 5/17/16
D
|
HW due: Finish working on
your Python version of the dayOfWeek function. You
will be granted approximately 30 minutes of class time to use to finish up
your code, or to help other groups finish theirs if yours is already
finished. By 3:00 p.m. today, each group should submit its source code by
e-mail, using a subject line of the following format:
__Source
code for assignment due 20160517 [Group 9, Smith/Zimmerman]
Here are the group numbers and team members:
Group 1: Nicole and Jose
Group 2: Kwaku and Chris
Group 3: Alex and Luca
Group 4: Elizabeth and Adam
Group 5: Ly-Lan and Rashaun
Group 6: Jordan and Katie
Group 7: Kevin and Alan
Group 8: Henry and Will
|
|
W 5/18/16
E
|
No class.
|
|
Th
5/19/16
F
|
In class: Review for final
exam.
Your dayOfWeek (Python version) code will be
accepted without penalty today.
In class: Review for final quiz.
|
|
F 5/20/16
G
|
End of Q4.
In class: Quiz (50 points) over general themes of the course (software
development, testing, etc.), followed by review for final exam.
|
|
W 5/25/16
|
Final Exam, 2:00–4:00 p.m., Trapier
Theater.
Mr. Hansen’s office hours for exam week are Monday 10:00-2:00, Tuesday
10:00-1:45, and Thursday 10:00-2:00. If you can’t finish your Excelcise during those times, you need to contact Mr.
Hansen ASAP!
|
|
F 5/27/16
|
Update!
There will be additional office hours on Friday, May 27, from 7:30 a.m. to
12:30 p.m. The following people need to be sure to stop by during that window
in order to pass the Excelcise:
Adam
Nicole
Rashaun
|
|