Michal Valko: CS0007 - Fall 2005
cs0007

News

  • 11/30 Assignment 4 graded
  • 11/21 Happy Thanksgiving!
  • 11/21 OMET survey was rescheduled for 11/29.
  • 11/18 Assignment 5. Due 12/08.
  • Submit to: /afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/hw5/
old news

Intro

course: #0007 Introduction to Computer Programming
title: cs-syllabus code: CS/28/LEC C16 TERM

lecture 11857 Tue 6:00 pm - 7:15 pm sensq 5505 John
lecture 11857 Thu 6:00 pm - 7:15 pm sensq 5505 John
recitation 12304 Tue 7:25 pm - 8:15 pm sensq 5505 Michal

office hours and phones

textbook: Java by Dissection by Ira Pohl and Charlie McDowell

textbook sensqclassroom

help:

e-mails:

  • instructor: wizzard ~ cs.pitt.edu
  • ta: michal ~ cs.pitt.edu

Recitations

Sep 06, 2005

10 steps how to write, compile, run and submit your first Java program from any computer with Internet access:

  1. obtain a @pitt.edu account
  2. download putty or use a F-Secure SSH from your lab
  3. connect to unixs.cis.pitt.edu (help!)
    use your pitt.edu username and password with ssh (secure) or telnet (insecure) connection
  4. learn about Basic UNIX Commands
  5. familiarize yourself with pico, joe, vim, mcedit or any other editor
  6. edit your program, name it usernamefirst.java (replace username with your username)
  7. compile, (javac usernamefirst.java)
  8. debug your source code, try to repair any errors
  9. run (java usernamefirst) remark: no .java extension here (help!)
  10. put your debugged .java source to
    /afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/rec1/
    cp usernamefirst.java /afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/rec1/
Using tio.jar package: download from web (tio.jar) and extract it in your directory:
  • wget http://../projects/courses/cs0007/tio.jar
  • jar xvf tio.jar
Sep 13, 2005

For this recitation you have to write an "age" programe from the scratch. The program take a number of years as an input and outputs the same time in seconds.

Example: unixs$ java miv8age
Please enter your age in years:
19
You have spent 599184000 seconds in this world.

Place your source file (usernameage.java) into
/afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/rec2/ directory.
When you are done, try to make some syntax errors and see what compiler respond.

Sep 20, 2005

  • slides
  • Recap & Loops (What are the loops for.)

Assignment 1 is out. It is due September 27, 2005.
Do not submit anything but your java source code. Example
cp miv8hw1.java /afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/hw1/

Sep 27, 2005

Debugging: Fix the code in multitab.java (source) so it can output a table with products.
Come up with an idea (and implement it) how to output the numbers to be aligned.

Casting

  • the cast operator (type) is used to convert numeric values from one numeric type to another or to change an object reference to a compatible type
  • used to enable conversions that would normally be disallowed by the compiler

byte a = 1;
byte b = 2;
byte c = a + b; // compiler error: a and b are promoted to int
byte c = (byte)(a + b); // compiles ok

Instead of c = (short) c + 2; we can have c+=2;

Assignment 1: Your program should ask for input 6 times. There are several methods for input in Console.in (from tio):
http://www.cse.ucsc.edu/~charlie/java/tio/v2/doc/tio/ReadInput.html

You can also notice, that when get out of range of particular variable you can experience negative numbers on output, such as 2*64 = -128 for byte (because byte is only from -128 to 127).

Corrections or What to do if I find a mistake once the file has been submitted?
If you want to resubmit your file, you will be not able overwrite your previous file. (You cannot delete, view, edit or overwrite any file in submission directories).
But you can submit your file under higher version. The file with the highest version number will be considered to be your final submission.
Example miv8hw6.java, miv8hw6version2.java, miv8hw6v3.java ...

Oct 4, 2005

Generating random numbers, Switch and Loops:
Oct 11, 2005

Loops (break & continue), Functions and Strings:
Oct 18, 2005

Frequent and noteworthy mistakes in Assignment 2:

  • not (re)initializing input number and comparing it to the random one, befor reading. It might happen (there is an 1% chance) that the number stored in inputNumber is the same as the random one:

    while(play) {
    ...
    number = (int)(Math.random()*100)+1;
    ...
    while(inputNumber != number)
    {
    inputNumber = Console.in.readInt();
    }

  • new random number - we need to generate new random number for every new game, otherwise new games do not have much sense.
  • division of integers gets us an integer (and we want a float/double for average) - check the 5th recitation

Functions and Arrays:

Oct 25, 2005

Review before midterm:
Nov 1, 2005

  • homework related questions
  • multidimensional arrays
  • game of life (top-down design example from the book)
Nov 8, 2005

  • assigment 3: noteworthy mistake
  • card/suit/pips classes
  • midterm
  • slides
Nov 15, 2005

  • clarifying some midterm related stuff, strings
  • more intuition about: objects, classes, ...
  • Predator/Prey example from the book, chapter 7, page 249-256
  • slides
Nov 29, 2005

  • OMET survey.
  • wrapper classes
  • static vs. instance
  • abstract vs. concrete vs. interface
  • intro to i/o
  • slides
Dec 06, 2005

8-Sep-2011