Friday, September 26, 2008

We spent some time on the board and the projector screen making sure that your understanding of conditionals is solid. You'll be using them all the time from now on so I want to make sure everybody's got it. Please make sure that you see me or email me if there's anything that you're unsure of about them.

Then we talked about compound Boolean expressions which sound more fearsome than they are. Compound Booleans or, if you'd prefer, compound conditionals, are just a simpler way to write what would otherwise be a series of nested if...else statements. Suppose we're trying to find people who are between the ages of 18 and 65 then we could write:



if(age >= 18)
if age( <= 65)
System.out.println("You're in the right age group.");


But wouldn't it be simpler to write:



if((age >= 18) || (age <= 65))
System.out.println("You're in the right age group.");



In terms of hands on work we/you wrote the Discriminant application on p108 and Hurricane on p109. Discriminant supports the use of nested if...else and the idea that we can test for negative numbers by testing for less than zero. Hurricane gives practice using the switch statement.

If you haven't already, once those two are done, go on to do Delivery on p112. Delivery involves the use of compound Boolean expressions.

I forgot to ask you to do homework (bad teacher!) so if you're feeling all keen and want to get ahead, then do p121, Qs 1, 2, 3, 4b, 5 and 6 to really lock in your understanding of conditionals. Otherwise expect to do these questions on Monday night.

Tuesday, September 23, 2008

Nothing special today. We wrapped up the presentation on variables, Java arithmetic and constants and spent the balance of the class working on your GradeAverage and TempConverter applications. Most people seem to have found their way through it.

Let me stress how important it is to keep up to speed on the application side of things. Most of what we are and are going to be learning is cumulative. 'C' builds on 'B' which was built on 'A', etc. If you get too far behind you will have trouble absorbing the new material as it will assume you (mostly) grasp what has been done so far.

Tomorrow, I'll finish off checking your TempConverter and GradeAverage applications. If you haven't finished them you need to start coming to the lab early before class starts (I'm there every day by 8:40 at the latest and, so far, actually by 08:10) and/or requesting that I stay in the lab at lunch for you to catch up. That will be mostly up to you to initiate the extra help process.

What's on the agenda for tomorrows class? Conditionals. These are the programming constructs that allow your program to start making decisions. In other words, some of the interesting stuff.

A last note, I would really, really appreciate any feedback from you guys as to what is working for you (Yay!) or, more importantly, what is not working. You can use the comment section on the blog or just talk to me. Or leave an anonymous note.

Monday, September 22, 2008

Testing, testing, 1, 2, 3

Homework for today is to read pages 105-110 in your text. We're starting what are called conditional control structures. This is the feature of the language that allows your program to make choices based on certain data. It's what allows your program to be responsive to input from outside itself.



OK. I tried to introduce number formatting using the NumberFormat class and confused the whatchamacallit out of you - for which I apologize. We'll go over it again at the top of tomorrow's class but here's some background.

I said that in order to use NumberFormat we needed to declare a NumberFormat object and I gave an example of such a declaration:
NumberFormat myFormattingObj = NumberFormat.getInstance();

The line of code above creates a new NumberFormat object called myFormattingObj.

I hesitated when saying that because I realized that it contradicted what I had previously told you (and what you'd just practiced in the test) about declaring new objects in Java. Marya picked up on in it right away. Shouldn't it be something like NumberFormat myFormattingObj = new NumberFormat();, she asked?

So, it turns out that there is special type of method in Java called factory methods whose particular job is to instantiate objects. (If you have 10 minutes at some point I can explain why it's a good thing to have such a special type.) The getInstance() method of the NumberFormat class is such a factory method. All it does is return a new object. Effectively, you could replace NumberFormatNumberFormat.getInstance(); in the declaration above with new NumberFormat(); For our purposes (and to the best of my understanding) it does exactly the same thing.



Aside from the mechanics of declaring an object using a factory method, it's probably confusing that you're declaring an object to do number formatting at all.

Think of myFormattingObject as like a small custom body shop or garage that you declare to do some work on your numbers.

First you create the body shop: NumberFormat myFormattingObj = NumberFormat.getInstance():

Then you tell the body shop how you want to customize your number: myFormattingObj.setMaximumFractionDigits(3);

This says to set the maximum number of digits to display to be 3.

Then you submit your number to the body shop to have the work done on it: myFormattingObj.format(numWithDecimal);

If your number was 5.678948, then the result of the the last bit of code would be 5.679.

Friday, September 19, 2008

Review for Monday's Test

Most of today was test review. [You know there's a test on Monday, right?] Please check the handout folder for a copy of the review handout (ICS3M_RvwNotes_1.doc) that we looked over in class.

I also asked a number of students (at random) to put questions from last night's homework on the board. No. one. (that I asked) had. done. it. Here's the threat. If no one sees fit to do the homework then I'm going to get all Grade 9-ey and start going round the class and checking homework and calling home and stuff. Let's not go there. Last warning.

On a lighter note, I mentioned a flash game that targeted the programming skill set. It's behind the school firewall but the link is here. It's neat and making it work does actually have something to do with programming skills. Check it out.

Last thing. I stumbled across this article on online literacy - or the lack thereof. The basic argument is that in spite of all the hopes that the "online experience" would produce a renaissance of literacy, the experience of consuming text online is somehow impaired. It certainly reflect my own experience consuming text online (and I spend a lot of time on the net). I'm all about loving computers and the massive uber-connectiveness that is the SeriesOfTubes but I'm also a long-time book reader from before the dawn of time (ca. 1966) with a big hardcopy library. There are some important ideas in the article.

Good luck on Monday. Have a good weekend!

Wednesday, September 17, 2008

Movin' On

Everybody pretty much finished up the ParseInteger program today. I'll post my solution soon.

We moved on to discuss typecasting and the situations in which it might be used and this led us to the notion that when typecasting a double to an int we should consider rounding the int values when doing it so as to preserve as much accuracy as possible.

We also discussed the order of arithmetic operations. Misunderstanding this order can lead to unexpected results in your programs. Be careful, it's a minefield out there, people.

There are two new applications to work on: GradeAvg and TempConverter from page 85 of the text.

There is also homework: page 97 Qs 6-10. I'd mentioned the possibility of doing Qs 13, 14, and 15 but we didn't get that far in the presentation today so we'll save them for later.

Parsing the Integer; Hunting the Snipe

Today was all about consolidating yesterday's admittedly confusing foray into integer and modulus division. (Sorry!) It seems like most of you get it, now, and should be able to finish your ParseInteger programs tomorrow.

Many thanks to all those students who were able to finish early and then move on to help others.

If there's one thing I want you to take away from today, it's some hints about the thinking process that you can (and should!) go through when confronted with a difficult programming problem.
  1. Write down what you're supposed to do. Write it down, even if it's already given to you written down. The actual act of writing it down shifts your brain into the problem space.
  2. Write down what you know about the problem. Don't worry too much about how organized it is. If you have pieces of the puzzle put them down even if you don't know how they fit together. This is just a version of the kind of brainstorming you might do before writing and essay or short story in English or the kind of noodling a musician might do when approaching a composition.
  3. Get a high-level design down on paper - just the big, gross steps of what you think needs to happen in the program. E.g. Get some input; Process some input; Print some Output.
  4. I didn't talk about this but the fourth thing is to experiment. Hack at it. Try some stuff and see if it works.
Don't forget to check my notes that I did on the projector today and put in the Handout Folder.

Tuesday, September 16, 2008

Divided We Fall

See slides 8 through 11 of ICS3M_1.9_VarsConsts_2.ppt for what we covered today. (Basically integer division and modulus division.) Everyone started work on the project/assignment (call it what you will) that's on slide # 11.

Here's a hint:

Assuming the user has input 647 then:
647 / 100 ==> 6
47 / 10 ==> 4
7 / 1 ==> 7

The challenge is that although you get 647 from the user you have to figure out how to get the 47 and then the 1 in order to perform the integer division on them. Could modulus division be the answer?

HEAR YE! HEAR YE! HEAR YE!
Mini-test next Monday the 22 of September on what we will have covered by then. There'll be a review on Friday's class.

Welcome to the ICS3M blog

Hi everyone,

Here's the plan. I'll use this space to put up announcements, homework and a brief summary of what we did on a particular day if it's applicable. Check in here if you were away and want to find out what to do.