## CPSC 124: Introduction to Programming

Department of Mathematics and Computer Science Hobart and William Smith Colleges Fall 2017. Instructor: David J. Eck (eck@hws.edu) Syllabus: http://math.hws.edu/eck/courses/cpsc124_f17.html Monday, Wednesday, Friday, 10:10–11:05 AM Room Gulick 2000 (formerly room number 206A). Lab: Thursday, 1:30–2:55 PM Room Rosenberg 009. Office hours in Lansing 313 (but also check the computer lab, Lansing 310): MWF, 11:15–12:10 WF, 2:00–3:00 (I am also often available at other times.)

Quizzes and Tests, with Answers | |||

Quiz 1, Sept. 8 | Quiz 2, Sept. 15 | Quiz 3, Sept. 22 | Test 1, Sept. 29 |

Quiz 4, Oct. 18 | Quiz 5, Nov. 25 | Test 2, Nov. 3 |
Quiz 6, Nov. 15 |

Quiz 7, December 4 |

### Some Useful Links

- Introduction to Programming Using Java, the textbook for the course.
- PDF version of the textbook, good for reading on-screen.
- Java 8 Documentation and API. (local access only -- from off-campus use Oracle's copy: Documentation and API)
- A Style Guide for Java Programming.
- About Linux — Local information about using Linux at HWS.
- Download Site for JDK 8,
where you can download a Java programming system for Mac OS or for Windows, if you want to be able to compile Java programs on
your own computer. Note that you want to download the "
**JDK**." - Download Site for Eclipse, which we will use for programming later in the course. Grab the "Eclipse IDE for Java Developers" if you want to use it on your own computer.

### First Week: August 28 and 30; September 2

Welcome to the course!

You should begin reading the textbook, which is available on-line at http://math.hws.edu/javanotes. During the first week of the term, we will go over some of the introductory material in Chapter 1 fairly quickly. We will cover only a part of Chapter 1 in class, but it is a good idea to read the entire chapter to get a preview of most of the topics that will be covered during the rest of the semester. However, you should not expect to fully understand everything in Chapter 1 at this time. The most important sections for now are Section 1 and Section 3. Sections 4, 5, and 6 give short overviews of many of the topics that we will cover in the rest of the semester, but they are not required reading at this time. Section 2 is not particularly relevant to this course, but contains some interesting information about the way computers work.

We will move very quickly into Chapter 2, which covers the most basic elements of Java programming. In fact, in the first lab, on Thursday, you will write your first simple Java programs. The lab web page will have enough information to get you started.

The required reading for the first week also includes the course handout!

### Second Week: September 4, 6, and 8

The reading for the week is Chapter 2,
Section 2.3,
Section 2.4, and
Section 2.5.
(There are a few topics in those sections that we will not cover, at least for the
time being, including 2.3.4 on Enums, 2.4.4 on Files, and 2.4.6 on *Scanner*.
We also won't be using the output functions from *TextIO*.)

In Section 2.3, we will be covering some mathematical functions and subroutines for use
with strings. In 2.4, we will encounter *TextIO.java*, which can be used for getting
input from the user on the command line. *TextIO* is not a standard part of Java.
I have written it to make text input more convenient. (The more standard alternative to
*TextIO* is the *Scanner* class.) And in 2.5, we will see some details of
mathematical expressions.

**The first quiz for this course will be this Friday, September 8, at the beginning of class.**

### Third Week: September 11, 13, and 15

We are moving on to Chapter 3
this week. The reading includes sections 3.1, 3.2, and 3.3.
Chapter 3 covers control structures, starting with basic if statements
and while loops in Section 3.1. Section 3.2 is an introduction to
how to think about developing correct algorithms for solving problems.
It introduces the ideas of *algorithm* and *pseudocode*.
Section 3.3 covers more details of *while* loops and
*do..while* loops, inclulding the *break* and *continue*
statements.

There will be another quiz this week, on Friday, September 15. You can expect some questions that ask you to write Java code segments.

### Fourth Week: September 18, 20, and 22

We will dive into *for* loops, Section 3.4,
on Monday. From there, we will jump to arrays, Section 3.8,
a kind of data structure that is often used with *for* loops. And on Friday, we will return to
Section 3.5, to talk about the
*if..else if..else* construction.

We have covered the *do..while* statement briefly. You should know what this statement means,
but you will not be required to use it on quizzes or tests. Similarly, you will not be required to
use any *switch* statements, even if we do cover it in class next week. You are, however,
definitely responsible for using all forms the *if* statement, *while* loops,
*for* loops, and the *break* statement.

You can expect another quiz this Friday, September 22. It will cover through Section 3.4
(that is, *for* loops but not arrays). The first test will be the following week,
on Friday, September 29.

### Fifth Week: September 25, 27, and 29

There is a test on Friday, September 29. A study guide will be handed out in class on Monday.

We will spend part of the week reviewing for the test and, in particular, doing more examples
with *if..else if* and with arrays. In any remaining time,
we will move on to new material.

The reading for the week is Section 3.6
and Section 3.7, but these sections will
not be on the test. Section 3.6 covers *switch* statements. You should be familiar with
them, but you will not be asked about them on quizzes or tests.
Section 3.7 covers the idea of *exceptions* as well as catching and throwing exceptions,
including the *try..catch* statement. Exceptions are an important topic, and eventually,
you will need to understand *try..catch*. We will cover them more thoroughly when we
need them.

In class on September 21, I demonstrated changing an "AdditionProblem" program into
an "ArithmeticProblem" program, which is part of what you need to do for L
Lab 4. Here is a link to that example
ArithmeticProblem.java. (There is
also a copy in */classes/cs124*

Here is a link to the Solutions for the sample test

### Sixth Week: October 2, 4, and 6

We will be starting Chapter 4 this week. The main topic is writing and using your own subroutines. (And remember that "method" is another name for "subroutine" in Java.) The reading for the week is Sections 4.1 to 4.4.

This week's lab is primarily about Eclipse, the IDE (Integrated Development Environment) for Java. There will be one short new exercise on writing subroutines. The due date for the work from last week's lab has been moved to next Friday. The work from both Lab 5 and Lab 6 will be due at 3:00 PM on Friday, October 13.

Sample answers from last week's test are available. There is no quiz this week. The next quiz will probably be the Friday after Spring break.

### Seventh Week: October 11 and 13

There is no class on Monday this week, because of Fall break.

After the break, we will continue with Chapter 4. The reading is Section 4.5 and Section 4.6. After looking at the basics of how subroutines are written and used, we move on to the bigger question of overall program design. We will discuss top-down and bottom-up design, software toolboxes and APIs, Java packages, and preconditions and postconditions as ways of reasoning about the behavior of programs.

Remember that your work from Labs 5 and 6 is due on Friday this week (at 3:00 PM) instead of on the usual Thursday.

There is no quiz this week. The next quiz will be next Monday, October 16, The next quiz will be next Wednesday, October 18, covering Sections 4.1 to 4.6.

### Eighth Week: October 16, 18, and 20

We are at the mid point of the semester, and it's time to move on to object-oriented programming. You have been using objects since the beginning of the semester, but now it's time to learn more about classes, objects, and the relationship between them. We will spend part of the class on Monday on Section 4.7 and then move on to Chapter 5. We will spend most of the rest of the week on Section 5.1, which covers some basic ideas about creating, using, and understanding objects.

### Ninth Week: October 23, 25, and 27

We will continue with Chapter 5. The reading for the week is
Section 5.2,
Section 5.3, and
Section 5.4.
We might start Section 5.5 by Friday. These sections continue
our study of classes, objects, and object-oriented programming.
We will be looking at several of Java's built-in classes, including
*Scanner*, *Random*, and *Array>ist*. (Note that
of these three, only *Random* is covered in Chapter 5.
*Scanner* was introduced in
Section 2.4.6,
which we did not cover at the time. *ArrayList* is in
Section 7.3,
but we will only be looking at its basic features at this point.

There will be a quiz on Wednesday of this week, covering Sections 4.7 and 5.1. And there is test coming up next week, on Friday, November 3.

### Tenth Week: October 30; November 1 and 3

There is a test on Friday this week. A study guide was handed out in class on Monday. I also handed out a list of questions from last year's second test. The answers to that test are on line at http://math.hws.edu/eck/cs124/s17/quizzes/test2.html. (Question 3 on that test is not on material that is included for the test this year.)

We will continue our discussion of designing classes on Monday, and Wednesday will be mostly review for the test. I hope to cover some new material on subclasses from Section 5.5, but for the most part we will be consolidating and reviewing this week.

### Eleventh Week: November 6, 8, and 10

The sample answers to last week's test are available.

For this week, you should read the rest of Chapter 5,
even though we will not cover every topic in those sections. We will finally get to
Section 5.5 on Monday. This section
covers central material on subclasses, inheritance, polymorphism, and abstract classes, and it will take us more
than one class to cover it all. For the rest of the week, we will cover other topics from
Chapter 5, including *this* and *super*, interfaces, and nested classes.

### Twelfth Week: November 13, 15, and 17

After finishing one more short topic (nested classes) from Chapter 5, we will spend the week on GUI programming. You should read as much of Chapter 6 as you can. You will find that you are already familiar with a lot of the material in that chapter, since we have been doing GUI programming in labs since the beginning of the semester. Now, however, we will be going over more details of event handling, components, and layout.

The next quiz will be on Wednesday, November 15. It will cover mainly Section 5.5 (subclasses, inheritance, abstract classes, and polymorphism).

### Thirteenth Week: November 20

Because of Thanksgiving, the only class this week is on Monday.

We should finish with GUI programming on Monday.

**Have a great Thanksgiving!**

### Fourteenth Week: November 27 and 29; December 1

For the last two weeks of the semester, we will return to the topic of arrays and ArrayLsits. Arrays were first introduced in Section 3.8, but there is a lot more to say about them in Chapter 7. ArrayLists, which we have encountered in class and in lab, are covered officially in Section 7.3. The reading for the week is Section&bnsp;7.1 through Section 7.3, and we will probably move on to Section 7.4 (searching and sorting) by Friday.

There will be a quiz on Monday of next week, December 4, covering Sections 7.1 through 7.3. That will be the seventh quiz and the last one for the course.