UNI. OF L'POOL

INTRODUCTION TO PROGRAMMING IN JAVA: COMP101

NOTE: This set of www pages is not the set of www pages for the curent version of COMP101. The pages are from a previous version that, at the request of students, I have kept on line.


CONTENTS

1. Overview
2. Lectures
3. Practicals and Course Work
3.1. Presentation of course work
3.2. Mark scheme
3.3. Late submission policy
3.4. Plagiarism and close collaboration
4. Java 2 Standard Edition 1.5 (J2SE 1.4)
 
5. Java Web Sites
6. List of example problems
6.1. Additional example problems
7. List of example code fragments
7.1. Additional example code fragments
8. Course book
9. Additional material



1. OVERVIEW

Description: COMP101 is the first year, semester one, "programming and problem solving by computer" module. The aim is to provide a comprehensive introduction to the software engineering of computer programs which produce solutions to problems. The development process (very broadly) divides into a number of stages: requirements, specification, implementation and system testing. Students will learn:

  1. How to analyse problems and devise algorithms to produce solutions to problems.
  2. How to formally specify algorithms.
  3. How to implement such specifications.
  4. how to test and analyse the quality of the implementations.

Problem analysis will concentrate on a top down approach. A number of specification techniques will be considered, but focusing on Object Oriented Design (OOD) techniques with the use of Nassi-Shneiderman charts for procedural aspects. Implementations will be in the Java Object Oriented high level computer programming language; thus the module will also provide a thorough overview of Object Oriented Programming. Program quality testing and analysis techniques considered include: limit testing, boundary value analysis, arithmetic testing, path testing and loop testing. Throughout the module students will have the opportunity to design their own programs and to solve a variety of problems. A sophisticated set of web pages have been produced to support the module (http://www.csc.liv.ac.uk/ ~frans/COMP101/comp101.html).

Teaching Method: Three lectures are given each week for the 12-week duration of the module. In addition, for one hour each week, students will work in a tutorial/practical setting under staff guidance. To this end students will be allocated to a tutorial groups.

 

Each group comprises some 10 students and is supervised by a "COMP101" tutor. The first "port of call" for any student who has a COMP101 related problem should be their COMP101 tutor. (Note: your COMP101 tutor should not be confused with your "personal" tutor who will deal with any personal/pastoral problems that you might have.)

Assessment: Assignments are carried out individually. Each assignment comprises a "stand-alone" problem which is to be addressed, using the object oriented software engineering approach taught on the module, to produce a computer generated solution. A grade will be returned for each assignment. The module is 100 % continuously assessed. All students will be required to obtain a satisfactory standard in the practical work so as to pass both the module and the year. To "pass" the year students must:

Have an overall average mark of 40% or more.
Must not have got less than 35% in any module (8 modules in all).
Can only have two marks between 35% and 40%.

Should you be unfortunate enough to fail COMP101 (and you really have to try to fail a continuously assessed module) you will be invited to sit a resit examination during the summer recess. Resit examinatioin usually take place over a three week spanning the end of August and the begining of September (see University WWW pages for exact dates). It is necessary to pass the resit exam if you wish to continue at the University. The resit examination takes the form of a 3 hour practical. The examination is held in the confines of the University; it cannot be taken at some other location more convenient to your home!




2. LECTURES

The module comprises 36 lectures as follows:

Week (Starting)Monday LectureWednesday LectureFriday LectureTutorial/ Practical
1 (25 Sept 2006) Welcome Overview of computer systems Directories and programming languages none
2 (2 Oct 2006)) Software engineering The Java programming language The principles of Object Oriented Programming (OOP) Tutorial 1: (non-assessed) The Windows operating system, WWW and text editing
3 (9 Oct 2006)) Data Categories of data and data types Input and formatted output Tutorial 2: (non-assessed) The UNIX operating system, CSNEWS, e-mail, compiling a Java program
4 (16 Oct 2006)) Arithmetic and the Math class Creating a test harness (plus note on method calls) Type conversion Practical 1: (assessed) Giant letters program
5 (23 Oct 2006)) The character type Expressions and statements Inheritance and class hierarchies (plus abstract classes and methods, and interfaces) Practical 2: (assessed) Floating Barge
6 (30 Oct 2006)) Selection (if-else) Selection (switch) Menu interfaces using switch statements Practical 3: (assessed) Projectiles
7 (6 Nov 2006)) For loop More on for loop While loops and the break statement Practical 4: (assessed) Triangle recognition
8 (13 Nov 2006)) Do-while loops Nested loops Random number generation Practical 5: (assessed) Estimations of PI
9 (20 Nov 2006)) Recursion Design and style review Compound data types and arrays Practical 6: (assessed) Poisson probability
10 (27 Nov 2006)) Array processing Unconstrained arrays Program errors and testing review Practical 7: (assessed) Quadratic equations
11 (4 Dec 2006)) Strings Arrays of Instances (plus note on aggregation) Parameter passing mechanisms Practical 8: (assessed) Card shuffle
12 (11 Dec 2006)) No lecture No lecture No lecture none



3. PRACTICALS AND COURSE WORK


3.1. Presentation of course work


3.2. Mark scheme


3.3. Late submission policy


3.4. Plagiarism and Close Collaboration




4. THE JAVA 2 PLATFORM STANDARD EDITION 5.0 (J2SE 5.0)

We will be using the suite of programs known as the Java 2 Standard Edition (J2SE 5.0) which is available free-of-charge (but subject to a licensing agreement) from Sun (the developers of Java) through their WWW pages at http://java.sun.com. The J2SE Software comprises the essential software required for writing and running Java programs. There is also a directory on documentation for all Java libraries (know as Application Programming Interfaces --- API) and a directory called the "Java tutorial". The J2SE, the API documentation and the tutorial occupy about 10 Mbyte each on disk (i.e 30 Mbyte all together).




5. JAVA WEB SITES

Java is a WWW language thus, not surprisingly, there are many Java web sites that can be accessed and which provide all sorts of useful Java information. Some notable sites include:

http://www.javasoft.com, Sun's Java site, the source for the J2SE and the primary reference ("standard") for Java.
http://www.gamelan.com, a good site for Java sources, information and interesting applets.
http://liverpooljug.symbiandiaries.com, The Liverpool JUG (Java Users Group).
http://www.javaworld.com, a monthly on-line magazine devoted to Java.
http://www.mhhe.com/eng cs/compsci/kamin The home page for Samual kamin, Dennis Mickunas and Edward Reingold's book "An Introduction to Computer Science Using Java" (McGraw-Hill, 1998).
http://www.csc.liv.ac.uk/~frans/COMP101/comp101.html, the Liverpool University Java web site (i.e. this and related pages).
http://www.javaspecialists.co.za/ Heinz Kabutz' higly technical Java Newsletter (not for beginners!).
http://www.cs.princeton.edu/~appel/modern/java/CUP/ CUP Parser Generator for Java (same functionality with respect to Java as YACC has to C) --- again not for beginners.



6. LIST OF EXAMPLE PROBLEMS (QUICK REFERENCE)

Here follows a list all the complete problems and solutions (using the COMP101 software development methodology) given as examples in the COMP101 notes:

WeekTitleDescription
3 Giant JavaStrings, classes and output methods.
4 Circle Doubles and use Math class constants.
4 Pythagoras Use of Math class methods (pow and sqrt).
4 2D Geographic Distance Type conversion (casts), passing instances as arguments, reusing user defined classes.
5 Lower to Upper Case Conversion The character type.
5 Vertical Motion Operators.
5 Cylinder calculation Inheritance and class hierarchies.
6 Power 4 Selection, simple if statement.
6 Linear Equation Selection, if-else statement.
6 Calculator Use of switch statement, and writing Boolean functions.
6 Temperature Conversion more examples of the use of switch statements.
7 ASCII Code Output "For" loops.
7 Arithmetic Progression More "for" loops, inheritance and class hierarchies
7 Factorial "For" loop with loop parameter decrementation.
7 Extended Factorial Application Even more "for" loops.
7 Euler's Number Approximation "While" loop.
8 Fibonacci sequence "Do-while" loop example.
8 Multiplication table Nested "for" loops and alternative implementation without nesting.
9 Random number generator "While" loops and "do-while" loops.
9 Decimal to binary conversion Recursion.
9 Metres to Yards, Feet and Inches conversion Simple constrained array.
10 Set I/OArray input and output.
10 Set intersectionWorking with unconstrained arrays.
11 Password verification String handling (character arrays).

6.1. Additional example problems

Additional example problems not included in the main body of the WWW material referenced above, but which have significant relevance to the material contained in the main body.

WeekTitleDescription
4 Sine, Cosine and Tangent Trigonometric ratios.



7. LIST OF EXAMPLE CODE FRAGMENTS

Here follows a list of example code fragments (as opposed to complete example problems and their solution) that can be found in the COMP101 notes.

WeekTitleDescription
2 Hello World 1 First ever Java program, simple output.
3 Data initialisation Class Examples of declaring and initialising data items.
3 Data initialisation Application Class Example application class with data initialisation.
3 Hello World 2 Simple input and output.
3 Integer input 1 Numeric input (and output).
4 Example class version 1 Illustration of method calls with return value.
4 Example class version 2 Illustration of method calls with argument passing and return value.
4 Test harness 1 "Test harness" program 1 (Pythagoras).
4 Test harness 2 "Test harness" program 2 (2-D geog. distance).
4 Rounding Distinction between casting and rounding.
5 Character input Using read to input single characters.
5 Operator evaluation Evaluation of operators, precedence rules.
5 Super/Sub class Inheritance and class hierarchies.
6 switch example 1 Use of the switch (case) statement.
6 Menu interface 1 Use of switch statement to create a menu style interface.
7 "Smiley" faces 1 For loop example.
7 Sequence of numbers Use of loop parameter in for loops (output).
7 sequence of even numbers Use of loop parameter in for loops (calculation).
7 Backward sequence of numbers Use of for loop with loop parameter decrementation.
7 Euler's numbers 2 Solution to Euler's Number problem implemented using a for loop.
7 "Smiley" faces 2 "Smiley" faces example implemented using a "while" loop.
7 Menu interface 2 Second version of Menu interface (with switch and while statements).
7 For loop examples Omitting parameters in for loop construct.
8 Integer input loop 1 Variable count "do-while" loop example.
8 Integer input loop 2 Same as "Integer input loop 1", but implemented using a variable count "while" loop.
8 Integer input loop 3 Same as "Integer input loop 1", but implemented using a variable count "for" loop.
8 Integer input loop 4 Continuous "do-while" loop with break statement.
8 "Smiley" faces 3 "Smiley" faces example implemented using a "do-while" loop.
8 Random number generator 2 Alternative solution to Random number generator example problem using the Random API class method.
9 Decimal to hexadecimal conversion Use of recursion.
9 Fibonacci Alternative (recursive) implementation of Fibonacci problem.
10 Array length example use of length variable.
10 Cube mapping Example of an array mapping operation.
10 Odd number filter Example of an array filter operation.
10 Average Example of an array folding operation.
10 Zip Example of an array zipping operation.
10 Set I/O Declaration of unconstrained arrays.
10 Variable count loop Loop testing illustration.
11 Dec2Hex 2 Declaration of arrays of instances.
11 String example 1 Declaration of instances of the class String.
11 String example 2 "Short cut" declaration of instances of the class String.
11 String operations Use of methods in the String class.
11 Call by value example Example of "call by value" parameter passing.
11 Call by reference value example Example of "call by reference value" parameter passing.
11 Hello World 3 Command line arguments.
11 Add up 1 Numeric (integer) command line arguments.
11 Scope rule example Scope rule illustration.

7.1. Additional example code fragments

Additional example code fragments not included in the main body of the COMP101 notes, but which have some relevance to the material contained there in.

TitleDescription
Hello World 4 More sophisticated input and output.
Char 2 String Character to string conversion.
switch example 2 Use of the switch (case) statement (date validation).



9. ADDITIONAL MATERIAL

Links to further Java notes which do not form part of the COMP101 syllabus but which may prove useful in the context of later modules in the 2nd and 3rd years of study. Note that these were developed using Java 1.4 (Java 4) so will not display any Java 5 features.

General:

GUIs AND THE AWT AND SWING PACKAGES:

Note: The following WWW page were commenced in January 2000 before Java Swing. However, I have converted many of the examples so that they now use the javax.swing classes as indicated below. I recommend using Swing where ever possible (you simply "swing" the components into place!).

APPLETS:

JAVA SPACES:




Created and maintained by Frans Coenen. Last updated 10 February 2015