0% found this document useful (0 votes)
261 views

Learning Guide Unit 1

This course is an introduction to computer programming. Programming is the art of explaining to a computer what you want it to do. Many different languages are used for writing computer programs.

Uploaded by

Visoth Chuon
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
261 views

Learning Guide Unit 1

This course is an introduction to computer programming. Programming is the art of explaining to a computer what you want it to do. Many different languages are used for writing computer programs.

Uploaded by

Visoth Chuon
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

name http://my.uopeople.org/mod/book/print.php?

id=8892

Learning Guide Unit 1

Site: University of the People


Course: CS1102 Introduction to Programming 1
Book: Learning Guide Unit 1
Printed by: Visoth Chuon
Date: Thursday, 3 February 2011, 12:39 PM

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

Unit 1: Introduction to Computers and Programming

Topics:
This unit will address the following topics:

Introduction to the operation of a computer


The Java Virtual Machine
Object Oriented Programming
User interface
Variables, Strings Objects and Subroutines of Java
Text Input and Output

Learning Objectives:

Become familiar with basic concepts of computer programming


Understand the Fundamentals of Object Oriented Programming
Acquire the basic skills for simple programming
Write simple programs in Java

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.

Downloading and Installing the JDK

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.

Downloading Installing an Editor PSPAD

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.

Other editing environments


If you prefer a different editor, we suggest one of the following:

jGRASP
Netbeans
Then select your operating system and the Java SE option

Netbeans installation Instructions http://netbeans.org/community/releases/67/install.html


Sun’s Java Tutorial: Getting Started
Sun provides a good tutorial for getting started using Java and creating the famous first program “Hello
World”. The link to the tutorial is given below.
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html

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.

Compile the program by using either:

File / Compile or

CTRL+F9 or

Click on the 4th icon from the right at the top bar (the one with 010 on it).

You should get the same Hello World!

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.

Chapter 1: The Fetch and Execute Cycle: Machine Language

Section 1.1 The Fetch and Execute Cycle: Machine Language


Section 1.2 Asynchronous Events: Polling Loops and Interrupts
Section 1.3 The Java Virtual Machine
Section 1.4 Fundamental Building Blocks of Programs
Section 1.5 Objects and Object-oriented Programming
Section 1.6 The Modern User Interface
Section 1.7 The Internet and the World-Wide Web
Quiz

Chapter 2: Programming in the Small I: Names and Things

Section 2.1 The Basic Java Application


Section 2.2 Variables and the Primitive Types
Section 2.3 Strings, Objects, Enums, and Subroutines
Section 2.4 Text Input and Output

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?

Post your first program in your Learning Journal.


Discuss any problems you may have encountered, and your enthusiasm at having written your first program, in
the Forum.

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).

1. Why are machine languages different from one another?


2. What does a computer do when it is presented with a stupid instruction?
3. What is the difference between an Assembly Language instruction and a machine language instruction ?
4. Why do we use languages other than Assembly?
5. How does the computer fetch a particular item in memory?
6. How much information is contained in a register?
7. Give examples of other 6 devices that can be made to work with a computer.
8. Describe the interrupt procedure.
9. Why do we need interrupts?
10. What is a device driver?
11. How do you use type cast to change a number into a letter?
12. Use type casting in a numerology example.
13. What happens when you use an arithmetic operator to combine values of different types?
14. What is a program counter?
15. What is asynchronous? Give examples of an asynchronous event.
16. What is a thread?
17. What is multitasking? Give 3 examples.
18. What happens when a thread is blocked?
19. What are some uses of interrupts?
20. What is the difference between synchronous and asynchronous?
21. What is the function of an Operating System?
22. What is the difference between a compiler and an interpreter?
23. Distinguish between an automatic type cast and a forced one.
24. Can information be lost in a type cast? Explain.

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

You might also like