COSC 1020 – Section A – Fall 2000
Introduction to Computer Science I

Instructor: Scott MacKenzie, Ross N603; Office Hours: Monday & Wednesday 3:30-5:00 p.m.

 

Last update: 13-Jan-01


Jan 13: Note #1 — Office hours during remediation period: Wednesdays, 9:30 – 12:00.


Nov 29: Note #2 — For Friday…

 

Write a Java program to make a copy of a file.  Include appropriate checks for (a) the correct number of command-line arguments, (b) the existence of the source file, and (c) overwrite permission if the destination file already exists.  Name the program JavaCopy.java.

(Solution: JavaCopy.java )


Nov 29: Note #1 — Re typos in Horstmann…  Note that there is a list of known typos on the book’s web site, which is reachable from the COSC 1020 “Links” page.  To go directly to the list of typos, click here.


Nov 27: Note #2 — For Wednesday…

 

Write a Java program to find occurrences of a string in one or more files.  Use command-line arguments to specify the string and the file(s) to search.  The output should show the results of the search by displaying the filename and lines where the string is found.  Name the program JavaFind.java.

(Solution: JavaFind.java)

                                                                                                


Nov 27: Note #1 — Here are the programs demo’d in class on Friday.

 

Encode.java.  This program receives text input from the standard input, encodes the text as per the telephone keypad, and outputs the result on the console.

 

Decode.java.  This program is the counterpart to Encode.java.  Encoded input is received from the standard input, decoded into text, and output to the console.  The comments in the source file provide additional information, for example, on the invocation syntax and the format of the required dictionary file.

 

Word.java and EncodedWord.java.  These class definitions are used by Encode.java and Decode.java.  Note that Word.java has changed slightly from the previous posting.  Further changes may occur as these classes are currently under development.


Nov 22: Note #1 — Here are some of the programs demo’d in class recently. 

 

First, BigIntFactorial.java.  This program computes the factorial of an integer of any size.  It uses Java’s BigInteger class in the java.math package.

 

Second, WordPredict.java.  This is the program demo’d in today’s class.  It predicts the n most likely words one is typing given a word stem.  To run this program, you’ll also need a word frequency dictionary file.  The two used in class today were wordfreq1.txt containing about 9000 unique words and their probabilites, and wordfreq2.txt containing about 65,000 unique words and their probablilities.  Both are based on the 90,000,000 words in the British National Corpus.  (wordfreq1.txt is smaller because it has a higher frequency threshhold for including words.)  You’ll also need Word.java, which defines the Word class used in WordPredict.java.  Have fun!


Announcements Archive


 

Notes (PDF format)

Example programs (“Y” prefix indicates use of the york package)

Primitive Data Types

 

 

Operators

Numbers.java YNumbers.java Operators.java YOperators.java Days.java YDays.java Hours.java YHours.java DemoPromoteAndCast.java

 

Relational Expressions

 

 

Precedence of Operators

 

Keyboard Input

DemoKeyboardInput.java YDemoKeyboardInput.java YDemoKeyboardInput2.java HeightConversion.java YHeightConversion.java

 

Strings

DemoStringRedundancy.java DemoStringMethods.java

 

Program Flow - Choices

DemoIfElseStatement.java YDemoIfElseStatement.java

Grades.java TaxRate.java

 

Program Flow - Loops

TableOfSquares.java YTableOfSquares.java JavaIsFun.java StringBackwards.java DemoBreak.java DemoContinue.java DemoInfiniteLoop.java DemoVariableScope.java

 

Organization of Java

 

 

Wrapper Classes

FindRanges.java

 

Math Class

Frequencies.java Height.java CapacitorCharging.java

 

String Tokenizer Class

CountWords.java CountWords2.java Palindrome.java

 

Class Hierarchy Update

 

 

Redirection and Pipes

EchoAlphaWords.java FilterDuplicateWords.java

 

Stream Classes and File I/O

 

FileStats.java YFileStats.java FileWrite.java YFileWrite.java

 

System Class

CountSeconds.java CountSeconds2.java

 

StringBuffer Class

 

 

Random Class

RandomBits.java RandomQuilt.java RandomQuilt.html RandomQuilt.class

 

Date and Time Classes

DemoDateTime.java DemoClock.java DaysToSummer.java

 

Defining Methods – Why?

 

 

Method Syntax

DemoMethod.java CountWords3.java Palindrome2.java StringBackwards2.java

 

Formatted Output

TableOfCubes.java TableOfSquareRoots.java

 

Input Validation

InputInteger.java

 

Recursion

Factorial.java Factorial2.java StringBackwards3.java

 

Debugging

Palindrome3.java StringBackwards4.java

 

Pass by Reference vs. Pass by Value

 

DemoPassByReference.java

Variable Scope – Revisited

 

 

Key Points

 

 

Arrays

DemoArray.java CubeIt.java DemoSoundArray.java DemoSoundArray.html DemoCommandLineArgs.java FindString.java RandomGen.java JavaType.java NumberStats.java euro.dat GraphData.java GraphData.html DemoRotate.java DemoRotate.html

 

Vectors

NumberStats2.java MedalWinners.java

 

Key Points – Arrays and Vectors

 

 

Defining Classes

City.java (with doc comments) CityTest.java

 

Extending Classes

Employee.java EmployeeTest.java Manager.java ManagerTest.java

 

Class Methods

Misc.java

 

When is a Class a Program?

 

 

Key Points – Defining and Extending Classes

 

 

javadoc

QuoteOfTheDay.java QuoteOfTheDay.html City.java (with doc comments) City.html