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/
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 |
textbook: Java by Dissection by Ira Pohl and Charlie McDowell
help:
- map of 5th floor @ sensq
- tech staff @ cs
- technology @ pitt
e-mails:
- instructor: wizzard ~ cs.pitt.edu
- ta: michal ~ cs.pitt.edu
Recitations
10 steps how to write, compile, run and submit your first Java program from any computer with Internet access:
- obtain a @pitt.edu account
- download putty or use a F-Secure SSH from your lab
- connect to unixs.cis.pitt.edu (help!)
use your pitt.edu username and password with ssh (secure) or telnet (insecure) connection - learn about Basic UNIX Commands
- familiarize yourself with pico, joe, vim, mcedit or any other editor
- edit your program, name it usernamefirst.java (replace username with your username)
- compile, (javac usernamefirst.java)
- debug your source code, try to repair any errors
- run (java usernamefirst) remark: no .java extension here (help!)
- 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/
- wget http://../projects/courses/cs0007/tio.jar
- jar xvf tio.jar
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.
- 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/
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 ...
Generating random numbers, Switch and Loops:
- slides
- assignment one is graded - e-mail/see me if you want to know your grade
- averaging program we did together (source)
Loops (break & continue), Functions and Strings:
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:
- homework related questions
- multidimensional arrays
- game of life (top-down design example from the book)
- clarifying some midterm related stuff, strings
- more intuition about: objects, classes, ...
- Predator/Prey example from the book, chapter 7, page 249-256
- slides

