Learning Guide Unit 1
Learning Guide Unit 1
id=8892
1 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Overview
Introduction
Download and Install Software
Test Installation
Reading Assignment
Exercise
Learning Journal Task
Labs
2 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Topics:
This unit will address the following topics:
Learning Objectives:
Tasks:
Download and install the JDK package and the PSPad editor.
Test your installations.
Do the Exercise.
Post your answer to the question in your Discussion Forum and follow it up with approximately 3-4
comments to other students’ posts. Rate other student’s posts.
Perform Lab 1
Perform Lab 2
Post your activities throughout the week in the Learning Journal and complete the Learning Journal
3 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
This course is an introduction to computer programming. Programming is the art of explaining to a computer
what you want it to do, in exact detail and in a language that the computer can understand. Programming is only
one part of computer science, but it is the most basic and most central part. It is an activity that requires you to
think logically, to solve problems, to express yourself clearly, and often to endure a certain amount of frustration
as you try to get your programs to work. The result, though, can be very rewarding.
This course has no prerequisites, although a general familiarity with computers would certainly be helpful.
Many different languages are used for writing computer programs. Some of the most important are: Assembly
language, C, C++, C#, Pascal, BASIC, Cobol, FORTRAN, Ada, Lisp, Smalltalk, Prolog, Perl, Python, Ruby, and
Java. It is impossible to learn all the different programming languages. Fortunately, it is possible to learn
principles and general techniques of programming that can be applied no matter what language you write in.
Although you will work with a specific language, you should try not to lose sight of the general ideas.
In this course, we will use the Java programming language. Java is a relatively new language, having been
introduced in 1995. In the years since its introduction, it has become one of the most important languages for real
application development. It is a very versatile language. Java can be used to write regular desktop applications
and to make "applets" that can appear on Web pages. Many complex interactive Web sites are written in Java,
and it can be used to write applications for many types of mobile phones. Even high-performance scientific
programming has been done in Java. Although C++ might still be the most popular language, Java seems to be at
least a close second at this point in time. Java has also become very popular for teaching programming.
4 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Before you can write and run Java programs, you need to install the Java platform on your computer system.
The Java platform is available free of charge from the java.sun.com web site. You can choose the Java®
platform and an editing environment specific to your operating system (e.g., Windows,Linux, Mac X, etc.) The
download page contains the information you need to install and configure the Java platform for writing and
running Java programs.
In this course, we will carry out several programming projects. Therefore, in addition to the Java Development
Kit (JDK) you should also install an editor.
1. Access http://java.sun.com/
2. Place the mouse on Downloads at the top bar and click on “Java SE”
3. Find the “Java SE Development KIT (JDK)” section and download its current update.
4. Select the platform that you want to install on (e.g. Windows)
5. Agree to the conditions and click on Continue
6. Chose the file and download it (around 73MB)
7. Return to stage 3. Place your mouse over the “Docs” of “Java SE Development KIT (JDK)” and click on
“Installation Guide”
8. Chose the right Platform and System (e.g. JDK / Microsoft Windows / Windows) and click on it
9. Follow the instruction in the Notes.
PSPAD
5 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
PSpad editor is one of many editors that supports the Java syntax and is able to invoke the Java compiler and the
interpeter.
1. Access http://www.pspad.com/
2. Choose your preferred language (e.g. English)
3. Click on “Download” and choose the version you want to download. The simplest will be “Installer.”
4. You might want to download additional add-ons (e.g. Spell Checkers) and extensions (many).
5. Install the program.
6. Setting up the link to the Java Compiler and Interpreter
a. Invoke PSpad
b. Click on “Setting” at the top bar
c. Click on “Highlighter Setting”
d. Click on “Java” in the left pane
e. Click on the “Compiler” tab
f. Fill in the information where Java is located as in the image example below adjusting the locations where
Java is installed on your computer and its version.
g. Click on “OK”
7. Using PSpad:
a. If you drag a Java program to the PSpad icon it will open displaying the program. (Of course you can do
this from “File” / “Open” and then selecting the Java file).
b. The fourth icon from the right (a page with 010 on it) is the Compiler / Interpreter icon. Click on it to
execute.
jGRASP
Netbeans
Then select your operating system and the Java SE option
Classpath
You will need to set your Java classpath. The Classpath is an argument set on the command-line, or
through an environment variable, that tells the Java Virtual Machine where to look for user-defined classes
and packages in Java programs.
Refer to one of these links:
http://en.wikipedia.org/wiki/Classpath_%28Java%29
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html
6 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Use the HelloWorld.java program provided in the Code library of this unit. Download it and place it in a
directory. We recommend that you will set up a directory that will be used for your programming activities
throughout this class. All the different subroutines that you will develop and additional ones that are required
(such as TextIO.java) should be located there.
The file HelloWorld.java contains the very basic HelloWorld program, which simply prints out the message
"Hello World!". Since we have not compiled this file for you, to run the program you must first compile the
source code file. To do this, open a DOS screen (Start / Run / type CMD and click on OK), navigate using the
CD command to the right directory and issue the command
javac HelloWorld.java
"javac" is the Java compiler program. (This is one case where you really need to use the command-line
interface). The result should be the HelloWorld.class file that is the compiled, Java-bytecode version of the Hello
World program. Now that the compiled program exists, you do not have to compile the program ever again,
unless you want to edit it and change what it does. Run the program with the command:
java HelloWorld
"java" is the name of the java bytecode interpreter. The computer will say hello to the world. (Note that you say
"java HelloWorld" to execute the class file, and not "java HelloWorld.class".) You now know how to compile
and run a program.
If this works okay, now is the time to test your PSPad editor:
Invoke the PSpad program.
Either load the HelloWorld.java program using the File / Open mechanism to locate the program or drag the
program into the main screen of the PSPad program or to its icon.
File / Compile or
CTRL+F9 or
Click on the 4th icon from the right at the top bar (the one with 010 on it).
Now check the editing facility by changing the message to Hello Beautiful World! and run it again. Watch for
the change of the output message.
7 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Thoroughly read the Syllabus for this course available in the General Information Section on the course home
page.
For this week, you should read all of Chapter 1 of the textbook and in Chapter 2, Sections 2.1 up to and
including section 2.4.
The textbook is accessible from the General Information and Forums section of the Course Home Page. You can
read the document online or download the pdf to your local computer (preferred). Be aware that the full
textbook in pdf is approximately 5.5 MB.
8 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Now write your first exercise, you will write a program that does a computation and prints out a result. Here are
some facts: Every year, 724 billion cubic yards of water flow out of the Mississippi. There are 1760 yards in a
mile. There are 365 days in a year.
Here is the question: How many cubic miles of water flow out of the Mississippi every day?
9 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
Answer any 10 of the questions below in your Learning Journal (before you look at the answers).
10 of 11 2/3/2011 12:39 PM
name http://my.uopeople.org/mod/book/print.php?id=8892
This course has a required lab component. The labs give you a chance to get hands-on experience with the
computer and with programming. Remember that you always have someone to help you get through the trouble
that inevitably arises by consulting your peers and instructor in the forums. The labs are however generally
intended to be individual work and unless otherwise instructed you should be completing them on your own.
Each lab will involve some programming. There might also be a few questions for you to answer in writing. You
should generate a lab report consisting of your answers to the programming and other exercises. Lab reports
should be completed by the end of the learning week. You may be asked to submit the lab report as an
assignment to be assessed by your peers.
In some cases, the lab will be a starting point for a longer programming assignment that you can work on for
several weeks.
11 of 11 2/3/2011 12:39 PM