Spring Semester 2005

Thu May 5
Final Exam in Rawles 100 @7:15-9:15pm today.

Wed-Sat Apr 27-May 4
Please make an appointment next week to discuss your final grade.

Final Exam is on May 5, 7:15pm-9:15pm in Rawles 100.

The code we discussed in class on Thu:

import java.io.*;

class ConsoleReader {
  BufferedReader b;
  ConsoleReader(InputStream a) {
    this.b = new BufferedReader(new InputStreamReader(a));
  public String readLine() throws Exception { 
    String line = b.readLine();
    return line;
  public double readDouble() throws Exception {
    String line = this.readLine();
    double result = Double.parseDouble(line);
    return result;

class One {
  public static void main(String[] args) throws Exception {
    ConsoleReader c = new ConsoleReader(System.in);  
    String name = c.readLine();
    System.out.print(name + ", number>");
    double x = c.readDouble(); 
    System.out.println("Good, " + name + ": " + x);
TBS in labs today and tomorrow.

Final exam next week on Thu 7:15-9:15pm (RH100).

Two problems to discuss in class today:

Then consider the following nested if statement.
if (x > 3)
  if (x <= 5) 
    y = 1;
  else if (x != 6) 
    y = 2;
    y = 3;
  y = 4;
If y has the value 2 after executing the above program fragment, ... then what do you know about x?

Second Example
Assume that x and y are integer variables, ... and consider the code fragment shown below:
if (x > 3) { 
  if (x <= 5) 
    y = 1;
  else if (x != 6) 
    y = 2;
} else 
  y = 3;
I hope you noticed the difference between it and the previous one.

You bet. Now the questions.

Question 1.

If x is 1 before the fragment gets executed what's the value of y after the fragment is executed? (Is it possible to give an answer to this question?)

Question 2.

Now erase the curly braces. What value must x have before the fragment gets executed, for y to be 3 at the end of the fragment?

This dialogue from Soliloquy (p. 161).

Sun-Tue Apr 24-26
Practical exams graded, grades posted.

Individual e-mail messages still forthcoming.

In class we continue the review for the final.

Here's an example, taken from this exam:

35. Assume the code fragment below.

Does anything change in the way z gets updated if we remove the else keyword?

if (x > y)
  z = z + 1;
else if (x <= y) 
  z = z + 2;
  1.   Yes.
  2.   No.
36. Assume the code fragment below.

Does anything change in the way z gets updated if we remove the else keyword?

if (! (x > y))  
  z = z + 2;
  z = z + 1;
  1.   Yes.
  2.   No.
37. Are these two code fragments equivalent (in terms of the value of x at the end of the fragment, when the fragment gets executed)?

Fragment 1 Fragment 2
if (x == 8) 
  x = x + 3; 
  x = 5
if (x == 8)
  x = x + 3;
if (x != 8) 
  x = 5;
  1.   Yes.
  2.   No.

Sat Apr 23
Homework Ten, to be posted today, will be a Bonus Assignment.

Details to follow.

Thu-Fri Apr 21-22
TBS One, Midterm Two and Midterm One exams to be returned in labs this week.

Grades for the TBS One exam are being posted right now, the Practical to follow.

Wed Apr 20
Here's the code developed yesterday in class:
class Magic {
  public static void main(String[] args) {
    int n = Integer.parseInt(args[0]);
    int[][] sq = new int[n][n];
    int i = sq.length - 1;
    int j = sq.length / 2;
    for (int k = 1; k <= n * n; k++) {
      sq[i][j] = k;
      int ni = (i + 1) % sq.length;
      int nj = (j + 1) % sq.length;
      if (   sq[ni][nj] != 0 
         || (i == sq.length - 1 && j == sq.length - 1)) 
        ni = i - 1;
        if (ni < 0) 
          ni = sq.length;
        nj = j;
      i = ni;
      j = nj;
    for (i = 0; i < sq.length; i++) {
      for (j = 0; j < sq[i].length; j++) {
        String num = "   " + sq[i][j];
        System.out.print(num.substring(num.length() - 3) + " ");
If you want to see it in action here it is:
frilled.cs.indiana.edu%java Magic 3
  4   9   2
  3   5   7
  8   1   6
frilled.cs.indiana.edu%java Magic 5
 11  18  25   2   9
 10  12  19  21   3
  4   6  13  20  22
 23   5   7  14  16
 17  24   1   8  15
frilled.cs.indiana.edu%java Magic 17
137 156 175 194 213 232 251 270 289   2  21  40  59  78  97 116 135
136 138 157 176 195 214 233 252 271 273   3  22  41  60  79  98 117
118 120 139 158 177 196 215 234 253 272 274   4  23  42  61  80  99
100 119 121 140 159 178 197 216 235 254 256 275   5  24  43  62  81
 82 101 103 122 141 160 179 198 217 236 255 257 276   6  25  44  63
 64  83 102 104 123 142 161 180 199 218 237 239 258 277   7  26  45
 46  65  84  86 105 124 143 162 181 200 219 238 240 259 278   8  27
 28  47  66  85  87 106 125 144 163 182 201 220 222 241 260 279   9
 10  29  48  67  69  88 107 126 145 164 183 202 221 223 242 261 280
281  11  30  49  68  70  89 108 127 146 165 184 203 205 224 243 262
263 282  12  31  50  52  71  90 109 128 147 166 185 204 206 225 244
245 264 283  13  32  51  53  72  91 110 129 148 167 186 188 207 226
227 246 265 284  14  33  35  54  73  92 111 130 149 168 187 189 208
209 228 247 266 285  15  34  36  55  74  93 112 131 150 169 171 190
191 210 229 248 267 286  16  18  37  56  75  94 113 132 151 170 172
173 192 211 230 249 268 287  17  19  38  57  76  95 114 133 152 154
155 174 193 212 231 250 269 288   1  20  39  58  77  96 115 134 153

Mon-Tue Apr 18-19
Midterm Two grades now posted. (The Practical and the TBS to follow tonight).

Here's a nice problem that was brought up by James W. Palmer, in three stages.

What's the output of this code:

int j = 0; 
for (int i = 0; i < 10; i++) 
  while (j < i) 
    j = j + 1; 
Now consider adding curly braces like this:
int j = 0; 
for (int i = 0; i < 10; i++) {  
  while (j < i) 
    j = j + 1; 
Or like this:
int j = 0; 
for (int i = 0; i < 10; i++) 
  while (j < i) {
    j = j + 1; 
Now run the three problems above with j <= i instead of j < i.

Sat-Sun Apr 16-17
Notes for Lab Eleven (last) have been posted.

Grading is in progress.

Thu-Fri Apr 14-15
PRACTICAL EXAM in labs today and tomorrow.

Here's the code we discussed in class (has nothing to do with the exam).

class LabNine {
  public static void reverse(double[] a) {
    for (int i = 0; i < a.length / 2; i++) {
      double temp = a[i];
      a[i] = a[a.length - i - 1];
      a[a.length - i - 1] = temp;
  public static double[] r_verse(double[] a) {
    double[] result = new double[a.length];
    for (int i = 0, j = a.length - 1; i < a.length; i++, j--)
       result[j] = a[i];
    return result;
  public static void main(String[] args) {
    double[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (int i = 0; i < x.length; i++) {
      System.out.print(x[i] + " ");
    x = LabNine.r_verse(x);
    for (int i = 0; i < x.length; i++) {
      System.out.print(x[i] + " ");
Homework Nine, posted today, is due next week, in lab (on paper).

Wed Apr 13
Today I am in the office only between 12-12:30pm and 4-5pm.

Tue Apr 12
Here's the code developed in class today:
class Bubble {
  public static void main(String[] args) {
    int[] a = new int[args.length];
    for (int i = 0; i < args.length; i++)
      a[i] = Integer.parseInt(args[i]);
    boolean sorted;
    do {
      sorted = true;
      for (int i = 0; i < a.length - 1; i++)
      if (a[i] > a[i+1]) {
        // Utilities.show(a);
        sorted = false;
        int temp = a[i+1];
        a[i+1] = a[i];
        a[i] = temp;
    } while (! sorted);
This relies on a utilities method:
class Utilities {
  public static void show(int[] a) {
    for (int i = 0; i < a.length; i++)
      System.out.print(a[i] + " ");
And here's the second method of sorting:
class Selection 
{ public static void main(String[] args) 
  { int[] a = new int[args.length];
    for (int i = 0; i < args.length; i++)
      a[i] = Integer.parseInt(args[i]);
    System.out.print("       ");
    int i = 0, j = 0;
    for (i = 0; i < a.length; i++) 
    { for (j = i + 1; j < a.length; j++) 
      { if (a[i] > a[j]) 
        { int temp = a[i];
          a[i] = a[j];
          a[j] = temp;
          System.out.print("(" + i + ", " + j + ") ");
        System.out.println("-----------------------------(" + i + ", " + j + ") ");
      System.out.print("       ");
      System.out.println("-----------------------------(" + i + ", " + j + ") ");

Mon Apr 11
The bonus problems dropbox (for 4-5-6) will close tomorrow at 11:59pm.

Sat-Sun Apr 9-10
The basic framework we set up for sorting, on Thu, in class:
class Bubble {
  public static void main(String[] args) {
    int[] b = new int[args.length];
    for (int i = 0; i < args.length; i++) {
      b[i] = Integer.parseInt(args[i]);
    for (int i = 0; i < b.length; i++) {
      System.out.print("  " + b[i]);
    boolean sorted = true;
    for (int i = 0; i < b.length - 1; i++) {
      if (b[i] > b[i+1])
        sorted = false;

Thu-Fri Apr 7-8
For the practical you will need to learn two algorithms well:

Both will be discussed in class this week and the next, so we need to understand them well.

They are mentioned in Soliloquy and will be analyzed thoroughly in class.

Wed Apr 6
Midterm Exam tonight in Rawles 100 (7-9pm).

What to review for the midterm:

Homework One (solutions)
Homework Two (solutions)
Homework Three (solutions)
Bonus 1-2-3 (solutions)
Homework Four
Homework Five (solutions)
Homework Six (solutions)
Bonus 4-5-6
Homework Seven (solutions)
Homework Eight

Midterm Exam Two is:

The best review is to go over your homework assignments one more time.

Tue Apr 5
Thanks to Jonathan Warren for being to first to notice these methods are needed:
class Utilities {
  public static int count(int[] a, int x) {
    int num = 0;
    for (int i = 0; i < a.length; i++) {
      if (a[i] == x) {
        num = num + 1;
    return num;
  public static boolean contains(int[] a, int x) {
    return Utilities.count(a, x) > 0;
Can you see why and where?

Mon Apr 4
For the Midterm on Wednesday please review Homework Assignments One through Eight.

Midterm Two (Wed 4/6 7-9pm RH100) will have the same format as the first one:

Sat-Sun Apr 2-3
Homework Eight, posted, is due on Tuesday, April 5, 11:59pm.

Solutions for Homework Six, Seven posted.

More practice problems will be posted, to help you prepare for the Midterm Exam next week.

Thu-Fri Mar  31-Apr 1
Date: Thu, 31 Mar 2005 15:15:15 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201 Spr. 2005 Distr. List <dgerman@indiana.edu>
Subject: First Test of Basic Skills

Dear A201/A597/I210 Friends,

The first test of basic skills is today and tomorrow in labs. You will 
receive a blue book and will need to solve three problems, like for the
first midterm exam. The exam is closed-book, and lasts two hours. If you
finish early, and after you turn in the exam you are allowed to use the
computer and test your solution(s). Before the end of the exam, you will
be allowed to turn in a correction sheet, if you decide so, in which you
can further describe your approach to the problems, and any way in which
the experiments factor into your understanding of how good your solutions
are. Thus we may be able to assign more accurate credit, and feedback on
the exam would be more instantaneous.

Your grade on the test of basic skills is going to be recorded for the
first midterm. Those who scored above 90 don't need to take the test of
basic skills. In those cases you would be coming to lab today/tomorrow
just to turn in Lab Eight and Lab Nine. Lab Nine could be turned in next
week as well and most of you have already turned in Lab Eight already.

If you have any questions or concerns please let me know.

... Adrian

Wed Mar 30
The Test of Basic Skills is Friday (counts as Midterm One make-up).

Problems to practice and get ready for it have been posted (under Wed Mar 30).

Mon-Tue Mar 28-29
Homework Seven is now due Thursday at the end of the day.

Slides to be used in the lecture on Tuesday, to introduce arrays.

Sat-Sun Mar 26-27

Congratulations to Min Jung for being the fastest to answer the min paper of Tue correctly.

Here's the answer to the minute paper of Thursday:

There are also other ways:

My preference though is the one described at the top. Hope this helps.

Fri Mar 25
Slides used in class on Thu.

Here are the pictures of our special guest stars so far:
Jake Turner Amber Kim

Still more to come in the lectures to follow.

Thu Mar 24
Today we should continue our discussion of Lab Nine, Homework Seven and Lab Eight.

Tonight's guests:
Amber Kim James Schmittler Sourav Roy Becca McKing

(With many thanks for their so graciously accepting our invitation).

Wed Mar 23
Here's the program we developed in class on Tue.

It has one (semantic) error, can you find it?

class LabEight {
  public static void main(String[] args) {
    Point c1 = new Point(3, 5);
    Circle a = new Circle(c1, 10);
    Point c2 = new Point(8, 3);
    Circle b = new Circle(c2, 100);
    System.out.println(LabEight.overlaps(a, b));
  public static boolean overlaps(Circle a, Circle b) {
     double r1, r2, d;
     r1 = a.radius;
     r2 = b.radius;
     d = a.center.distanceTo(b.center); // System.out.println(r1 + " + " + r2 + " vs. " + d);
     if (r1 + r2 < d) {
       return true; // really?!... what's true supposed to mean here? 
     } else {
       return false; // false what? It's false that the circles DON'T overlap, correct? Ha!

class Circle {
  Point center;
  double radius;
  Circle(Point c, double r) {
    this.center = c;
    this.radius = r;

class Point {
  int x, y;
  Point(int x, int y) {
    this.x = x;
    this.y = y;
  double distanceTo(Point other) {
    int x1 = this.x, y1 = this.y,
        x2 = other.x, y2 = other.y;
    return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));

Tue Mar 22
Homework Seven, reading assignments for the week posted.

Mon Mar 21
Welcome back, more announcements will be made tomorrow.

Sun-Sun Mar 13-20
Happy Spring Break to everybody!
Fri-Sat Mar 11-12
Dropbox for Homework Six reopened for one more day (today).

It will close tonight at midnight. Solutions to be posted tomorrow.

Thu Mar 10
Today in class we will examine objects with BlueJ (follow-up to lecture notes 17).

Here's a short plan for problem 9 (see the note posted on Mar. 2-3 as well, below):

Hope this helps.

have also been designed to be of help.

Wed Mar 9
I won't be able to keep morning office hours today, I will be in only in the afternoon.

Also, Jeremy is changing his office hours this week only from Wed 10-11 to Thu 4-5pm, location is the same.

Tue Mar 8
Lecture Notes Seventeen have been posted.

Mon Mar 7
BlueJ can be downloaded for free from here.

DrJava can be downloaded for free from here.

In both cases you need to have Java installed already.

You should continue to be able to run everything from the command line, if need be.

Sat-Sun Mar 5-6
Official handout for Homework Six posted as part of the assignment.

More information on the announced Test of Basic Skills has been posted.

Homework Six is being posted as you read this line of text (made up of tokens and chars).

Also note:

Solutions for Homework Five and grading guidelines have been posted, as well.

Fri Mar 4
Starting with Homework Six, Javadoc comments will replace printed reports, details forthcoming.

Homework Six to be posted later today (is briefly explained below, handout needs to be created).

Wed-Thu Mar 2-3
Homework Six will be posted tomorrow (Fri 3/4).

It will contain 9 problems, 4 of which are bonus problems.

There is also a solved problem, to get you started (in four stages):

  1. One.java
  2. Two.java
  3. Three.java
  4. Four.java

The problems are:

  1. Count the number of lines in a file (solved, above)
  2. Count the number of words in a file
  3. Calculate the average number of words per line in a file
  4. Calculate the average length of a line in a file (in characters)
  5. Calculate the average word length per line in a file
  6. Calculate the average word length in a file
  7. Find and print the longest line in a file
  8. Find and print the line with most words
  9. Make a copy of a file
  10. Search for a word in a file and replace it

It's up to you what 5 problems you choose to solve for credit.

Every problem in addition to those 5 is bonus.

Tue Mar  1
Lecture and lab notes for this week have been posted.

Fri-Mon Feb 25-28
We're going to set up individual appointments before we get (in)to the break.

And here are a few thoughts that I would like you to be guided by, with your permission.

Wed-Thu Feb 23-24
Gradebook updated, Homework Five posted, slides to help with it.

Tue Feb 22
Today in class, these slides, to help with Homework Four.

Fri-Mon Feb 18-21
Midterm One grades posted, in OnCourse.

Notes for this upcoming week posted. More to come soon.

Thu Feb 17
Homework Four, posted, is due a week from today.

Wed Feb 16
Slides from the lecture yesterday posted (lecture notes 11).

Midterm Exam today (7-9pm in Rawles 100).

Here are the Homework Three solutions.

Tue Feb 15
Here's the code for the second problem on the midterm sample:
class Time {
  public static void main(String[] args) {
    ConsoleReader c = new ConsoleReader(System.in); 
    System.out.print("First time: "); 
    String t1 = c.readLine(); 
    System.out.print("Second time: "); 
    String t2 = c.readLine();     
    int h1, m1, h2, m2; 
    h1 = Integer.parseInt(t1.substring(0, 2)); 
    h2 = Integer.parseInt(t2.substring(0, 2)); 
    m1 = Integer.parseInt(t1.substring(2)); 
    m2 = Integer.parseInt(t2.substring(2)); 

    int time1 = h1 * 60 + m1, time2 = h2 * 60 + m2; 

    if (time1 <= time2) {

      System.out.println( (time2 - time1) / 60 + " and " + (time2 - time1) % 60 + " minutes."); 

    } else { 

      time2 = time2 + 24 * 60; 

      System.out.println( (time2 - time1) / 60 + " and " + (time2 - time1) % 60 + " minutes."); 



Mon Feb 14
Here's the solution to the first programming problem on the first sample midterm:
class Months { 
    public static void main(String[] args) {

	String monthNames = "January   " +
                            "February  " +
                            "March     " +
                            "April     " +
                            "May       " +
                            "June      " +
                            "July      " +
                            "August    " +
      	                    "September " + // longest
                            "October   " +
                            "November  " +
                            "December  "    ;

	// open a connection with the keyboard 
	ConsoleReader console = new ConsoleReader(System.in); 

	// greet the user, and ask for input 
	System.out.println("Please enter a month number from 1 to 12."); 
	// get month name 
	int month = console.readInt(); 
	// report the name of the month 
            monthNames.substring("September ".length() * (month-1), 
                                 "September ".length() * month));

	// formula uses the length of the longest name 
It also appears somewhere in the text.

Notice that no if is needed.

Sun Feb 13
How the bonus works:
  • assume your grade on Homework One is a 70
  • and you turned in only two problems in Homework Two (which gave you a 18 or so)
  • and in the third Homework you anticipate receiving a 70 (about 158 points in total).

Each problem is about between 7.5 and 9.5 points.


  • solving 2+8+2=12 problems from the additional (bonus) packet
  • would bring your three assignments' total around 270
  • (which is an average of 90)

... so you'd get A's in the first three assignments this way.

Hopefully this clarifies the makeup/bonus procedure even further.

The bonus problems handout has been updated.

Here's the message sent to the list yesterday, grades will be up during the night:

Date: Sat, 12 Feb 2005 15:04:48 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201/I210/A597 Spr. 2005 Distr. List <dgerman@INDIANA.EDU>
Subject: A201/I210/A597 update (midterm exam Wed 2/16) 

Dear A201/I210/A597 Friends,

I have posted a sample midterm and I have updated the Homework Three
handout. I will post another sample midterm, with solutions, and update
the Bonus Problems handout tomorrow. Also, tomorrow, I hope to have the
grades for the first two homework assignments and the first four labs in
the gradebook in their entirety. So we can approach the first midterm on
Wednesday with a full gradebook.

My office hours on Monday are: 10am-2pm
                on Tuesday:     9am-3pm
            and on Wednesday:   9am-4pm.

The exam is on Wednesday between 7-9pm in Rawles 100.

Two observations/clarifications about lab grades and homework makeups:

a) you can improve your lab grades if you visit your instructors in their
office hours. Lab grades are just the start of a dialogue in which you're
encouraged to demonstrate your knowledge in an extensive way. Instructors
will use this dialogue as an opportunity to teach and examine. Lab grades
received in lab can be worked on further in office hours!

b) solving problems from the first batch of Bonus Problems will give you
bonus points that you can apply towards Homework Assignments 1, 2, or 3.
Every bonus problem is worth about 8-9 points and must be solved, turned
in with a brief report, as for a regular homework assignment. There is a
separate dropbox for bonus problems. They're good practice for the exam.

Everything is due Tuesday so I can post solutions for everything on Wed
morning. If you have questions please let me know. Remember that a 90 on
the grading scale is an A (the lowest). This is not a percentage, it is a
number of points. 95 is the highest A, above that we have A+.

Good luck with everything and I will write again tomorrow.

... Adrian

P.S. If you have received this message in error please let me know so I
can take your name off the distribution list. Thanks a lot for your hard
work and interest and dedication. It is a pleasure to work with such a
creative and enthusiastic group of students and associate instructors.

Sat Feb 12
A sample midterm and additional help/info with Homework Three posted.

Solutions for Homework Two programs have been posted.

Thu-Fri Feb 10-11
Lecture Notes Nine have been posted.

Homework Makeup Group 1-3 will look like this.

More details soon.

Tue-Wed Feb 8-9
Here's what Homework Three looks like. More examples will be posted soon.

Fri-Mon Feb 4-7
Here's a set of notes trying to help with Homework Two.

Thu Feb 3
Grades for Homework One soon to be posted with feedback by e-mail.

Meanwhile here are the solutions to the ten problems in Homework One.

Lecture Notes Eight, Lab Notes Four posted.

Wed Feb 2
There will be a chance to make up Homework One next week.

Everybody will have that chance (although it's likely that only few will use it and even fewer really need it).

In any event to qualify for the Homework One makeup you need to have turned in Homework Two on time.

So please focus on Homework Two and please come prepared to ask questions tomorrow.

Tue Feb 1
Lecture Notes Seven and minute paper question posted.

Fri-Mon Jan 28-Jan 31
Message posted to the Distribution List Sun. afternoon:
Date: Sun, 30 Jan 2005 13:02:04 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: A201/I210/A597 Spr. 2005 Distr. List <dgerman@cs.indiana.edu>
Subject: Homework Two posted. 

Dear A201/I210/A597 Friends,

Homework Two has been posted, last night, if you want to take a look at
it. It will be due on Feb 8 (Tue), in lecture. We will discuss it in class
this week (in lectures and lab). I am grading Homework One, grades should
be up soon, likely on Monday night. If you have any questions or concerns
please let me know. I hope your weekend is coming along fine.

... Adrian
Homework Two has been posted (and is due Feb 8).

Thu Jan 27
Today I will briefly use this file in class.

Homework One is due in class today.

Lecture Notes Six announce the new topic through a set of problems.

We will be working on them in class today.

Wed Jan 26
Type of program resembling Problems 3 and 4 in Homework One:

We developed this program in class yesterday:

frilled.cs.indiana.edu%ls -ld Program.java
-rw-r--r--  1 dgerman faculty 747 Jan 25 17:12 Program.java
frilled.cs.indiana.edu%cat Program.java
 *                                  * 
 * Program written by Adrian German *
 *                                  * 
 * Lecture Five A201 - Jan 25, 2005 * 
 *                                  * 

class Program {
  public static void main(String[] args) {
    ConsoleReader craig; 
    craig = new ConsoleReader(System.in); 
    System.out.print("Number in (0, 1): "); 
    double x; 
    x = craig.readDouble(); 
    System.out.println("You have entered " + x); 
    // calculate x * (1 -x) for ten times

    double x0; 
    x0 = x * (1 - x); 
    System.out.println("Stage zero: " + x0); 

    double x1 = x0 * (1 - x0); 
    System.out.println("Stage one: " + x1); 

    double x2 = x1 * (1 - x1); 
    System.out.println("Stage two: " + x2); 

    double x3 = x2 * (1 - x2); 
    System.out.println("Stage three: " + x3); 

    double x4 = x3 * (1 - x3); 
    System.out.println("Stage four: " + x4); 

frilled.cs.indiana.edu%javac Program.java
frilled.cs.indiana.edu%java Program 
Number in (0, 1): 0.34
You have entered 0.34
Stage zero: 0.2244
Stage one: 0.17404464
Stage two: 0.1437531032872704
Stage three: 0.12308814858254977
Stage four: 0.10793745626106992
Here's the report I would write about this program:

The program needs to read a value, call it x0, from the user. The value needs to be printed.

We then need to calculate a new value, call it x1, using the formula

x1 = x0(1 - x0)
and print x1 to the screen.

Then out of the new value x1 we need to calculate a new value x2

x2 = x1(1 - x1)
and print that as well. And we need to keep going like that for ten steps.

So here's how my program works:

  • I choose a name for a ConsoleReader (I will use craig).
  • So declaring a variable,craig, of type ConsoleReader is how I start.
  • I then create an actual ConsoleReader and call it craig (through an assignment statement).
  • I prompt the user for an initial number.
  • I declare a variable x, to hold the user's input value.
  • The variable is of type double (necessarily).
  • I read the user's value into x.
  • (That is, the righthand side reads the value which is then assigned to x).
  • I print the value.
  • Now for ten times I do the following three steps.
    1. I declare a new variable.
    2. I calculate the new value out of the old
    3. I store this value in the newly declared variable,
      and print the value for this stage.
    (After each stage the new value, once printed, becomes an old value).

  • After the last value is printed the program ends.

This concludes my report for this problem.

Tue Jan 25
Lecture Notes Five posted, reading assignments updated.

Mon Jan 24
What's the value of "\n".length()?

How about "\"\\\nice".length()?

Sat-Sun Jan 22-23
Lectures Notes One, Two and Three also updated to give them a bit more structure.

Lecture Notes Four have been updated a bit, to give them a little more structure.

Comments on the first part of the exercises presented in Lab Notes Two.

Thu-Fri Jan 20-21
Here's the note sent to the lab instructors on Thursday:
Date: Thu, 20 Jan 2005 13:40:02 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To:  ferdinc@indiana.edu, dgaunt@indiana.edu, aalkasim@indiana.edu,
     jtengle@indiana.edu, pmendygr@indiana.edu, zdwiel@indiana.edu,
     bjaffe@indiana.edu, satmarti@indiana.edu, dbulwink@indiana.edu,
     dgerman@indiana.edu, okcha9@yahoo.com
Subject: A201 labs, week two 

Dear A201/A597/I210 Friends,

Lab notes for tonight and tomorrow have been posted. We started with an empty program, 
a class with an empty main method inside, and progressively added printing (of strings 
and numbers, then expressions). We discussed +, -, *, /, % and the difference between 
int and double. We have introduced the concept of variables (names of locations that 
store values of certain type). We have explained the notion of casting in reference to 
storing an integer value into a floating-point variable and attempting to do the same
the other way around: a floating point value can't be stored in a variable of integral 
type unless you explicitly give up the fractional part through casting. A class,  
ConsoleReader, that can be used to read input from the keyboard was introduced. The 
use of ConsoleReader was described in reference to the Lab One example involving Penguins. 
Strings are Penguins too and this week we focus on the difference between Strings and numbers 
and methods by which one can convert between the two types. A few examples will be worked out
in the lecture tonight and the lab notes' purpose is to offer additional opportunities to 
explore and experiment. There is a lab assignment for next week (questions plus two programs). 
Homework Zero will be collected today and Homework One (ten problems) is due next Thursday. 
Next week we start programming with if statements we have been hinting at the boolean type ever
since we printed 1 + 2, 3 * 4 and 1 < 4.

Today you go to labs and need to grade their students on their first lab assignments. Here's 
a grading scale and a few suggestions on how to do it. Immediately after the lab please send 
me the usernames of the students in your lab tonight (and tomorrow) and their grades. They 
need to have done:

a) the Penguin program. Please check that:
   0. they have compiled and run and understod Dance/One.java  (10 pts)
   1. they are able to create a Rink of the right size         (10 pts)
   2. they are able to place the Penguin where you tell them   (10 pts)
   3. they can list three things that a Penguin can do         (10 pts)

b) the staircase program. Please check that:
   0. they can write "Hello world!" from scratch               (10 pts)
   1. they understand the difference between print and println (10 pts)
   2. they can print double quotes                             (10 pts)
   3. they can print slashes                                   (10 pts)
   4. they can print new lines                                 (10 pts)

All of this amounts to 90 points which is the lowest A. Please do not give more than 
90 points at this early stage unless students turn in a program or point out things that 
make you want to share them with the other students. Be supportive and patient with your 
teaching but quite conservative with your grading at this stage in the course.

I would like to merge three labs:

a) 3422 (Jeremy) should go to 3421 (SB221 Fulya) for the semester
b) 3425 (Fulya) should go to 3424 (SB221 Dan) for the semester, and
c) 3426 (Paul, Sara) should go to 3427 (BH308, Adrian) for the semester.

This way there will be more AIs and more students in the same room and hopefully the 
synergy would be better.

I will be visiting all the labs this week. I will stop and briefly touch base with every 
student. I have their pictures in a folder, one student per page, where I also record their 
minute papers. I am sure in two or three weeks I will learn them all.

Have a great Lab Two!

If you have questions or need help please let me know.

... Adrian
Lab Notes Two have been posted. Thanks also to Okcha Atwood for suggesting the following link:
The link is off the Java Tutorial website from Sun (the starting point of the tutorial is here).

Wed Jan 19
Lecture Notes Four posted, Lab Notes Two to follow.

Tue Jan 18
Homework Assignment One (due next week, Thu 1/27) has been posted.

Sun-Mon Jan 16-17
Class notes web page updated, contains full information about the course.

Also please note that Homework Zero is a Bonus Assignment.

Sat Jan 15
Congratulations to:

Wesley Michaels

For putting a new spin on Problem 2.2.1 (The Captive Queen).

He asks: "Can two people ride in a basket once?".

Good point! What if they can, what if they can't?

Fri Jan 14
Here's the message sent yesterday to all the instructors in this course:
Date: Thu, 13 Jan 2005 15:55:11 -0500 (EST)
From: Adrian German <dgerman@cs.indiana.edu>
To: ferdinc@indiana.edu, dgaunt@indiana.edu, aalkasim@indiana.edu, 
    jtengle@indiana.edu, pmendygr@indiana.edu, zdwiel@indiana.edu, 
    bjaffe@indiana.edu, satmarti@indiana.edu, dbulwink@indiana.edu, 
Cc: dgerman@indiana.edu
Subject: Re: office hours, assignments to labs 

Labs start today. Notes for this week and the first assignment (numbered
zero) have been posted. The homework assignment is due in writing, at the
time of the lecture next week on Jan 20. This week's lab will give you an
opportunity to introduce yourselves, and get to know the students. There
is a lab assignment that comes with the notes for this week. It's due next
week, in lab. You will go to the student and ask to see the assignment and
ask her/him a few questions about it or anything that we have covered thus
far. Every lab will come with a lab assignment due a week after. Students
are supposed to briefly present/defend their work in person. No submission
to OnCourse is necessary, unless otherwise mentioned.

For today's lab please make sure that all students are clear on what has
been posted in Lecture Notes One and Two. That is, create a simple program
with Notepad and compile it, then modify it to print simple expressions as
illustrated in class/lecture notes. Ask students if they have questions and
when they say they don't make up some questions for them. This will bring
the reality closer and you will be able to understand them better.

So basics (from Lecture Notes One and Two) and clarification of the lab
assignment for next week is what you should cover this week in lab. Make
sure you sit down with each student, take their name and username, check
they are getting started on the right foot and otherwise start learning
them. It will be a very rewarding experience for them and you alike.

Please make sure you touch base with each student. While in lab you're
allowed to use the instructor desk/workstation only for presentations. We
need to be walking around the room or sitting down with students at their
workstations for the entire duration of the lab, unless you need to make
a presentation on the projector (password: ____, not sure) to the class.

The assignment of the instructors to labs is as posted.

If you have any questions or concerns please let me know.

Thanks again for your most generous help and all the very best.

... Adrian

On Tue, 11 Jan 2005, Adrian German wrote:

> I've posted a schedule of office hours and the assignment of instructors
> to labs at http://www.cs.indiana.edu/classes/a201. Please check the posted
> information and let me know if anything is wrong. Otherwise labs start Thu
> night. We'll try to merge 3420-3421-3422 into one section and 3424-3425 as
> well as 3426-3427 after the first week of classes.
> Hope all is well with everybody, the class starts today at 4pm.
> ... Adrian

Thu Jan 13
Lecture Notes Two, to be used in lab today and tomorrow, also posted.

Here's the PDF for Homework Zero. (It will be indexed in the class notes later today.)

Lab notes for today, containing Lab Assignment One (due next week), have been posted.

The Powerpoint presentation of Tuesday.

Wed Jan 12
A201 message board has been created.

Tue Jan 11
Files we might need to demo today:

A201 starts.

First lecture in Rawles 100 at 4pm.

Mon Jan 10
Spring semester of 2005 starts.

Here's a link to A201's entry on the Registrar's web site.

Updated by Adrian German for A201/A597 and I210