IT 112 Module 1 SY 2022 2023
IT 112 Module 1 SY 2022 2023
INSTITUTE OF
COMPUTING
COMPUTER
PROGRAMMING
1
COURSE MODULE
AY 2022-2023
Prepared by:
JOVITO P. BOLACOY, JR. REIR ERLINDA E. CUTAD, DIT ARIEL O. GAMAO, DIT
THIS MODULE IS A PILOT TEST ONLY; NOT FOR REPRODUCTION AND DISTRIBUTION OUTSIDE
OF ITS INTENDED USE.
THIS IS INTENDED ONLY FOR THE USE OF THE STUDENTS WHO ARE OFFICIALLY ENROLLED IN
THE COURSE/SUBJECT.
©2022
Table of Contents
Module 1: Overview about Computer Program, Programming
Process, and Overview of Java
COMPUTER PROGRAMMING 1
COMPUTER
PROGRAMMING
1
MODULE
1
OVERVIEW ABOUT COMPUTER
PROGRAM, PROGRAMMING
PROCESS, AND OVERVIEW OF JAVA
Prepared by:
JOVITO P. BOLACOY, JR. REIR ERLINDA E. CUTAD, DIT ARIEL O. GAMAO, DIT
THIS MODULE IS A PILOT TEST ONLY; NOT FOR REPRODUCTION AND DISTRIBUTION OUTSIDE
OF ITS INTENDED USE.
THIS IS INTENDED ONLY FOR THE USE OF THE STUDENTS WHO ARE OFFICIALLY ENROLLED IN
THE COURSE/SUBJECT.
©2022
Table of
Contents
Module 1: Overview about Computer Program, Programming
Process, and Overview of Java
COMPUTER PROGRAMMING 1
Module 1
Computer Programs,
Algorithms, and Flowcharting
Welcome to Module 1!
Hello! Welcome to our first module. You will be learning about the history
of computer programs, algorithm and flowchart design, Java fundamentals,
and a lot more. Are you ready? Let's go.
Module Outcomes:
COMPUTER PROGRAMMING 1 1
Module 1: Lesson 1
Computer Programs,
Algorithms, and Flowcharting
LEARNING OUTCOMES
INTRODUCTION
COMPUTER PROGRAMMING 1 2
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
ACTIVITY
Step 1:____________________________________________________________
Step 2:____________________________________________________________
...........:____________________________________________________________
...........:____________________________________________________________
...........:____________________________________________________________
Step (n):____________________________________________________________
ANALYSIS
ABSTRACTION
Programming is, quite literally, all around us. From the take-out
we order, to the movies we stream, code enables everyday actions
in our lives. Tech companies are no longer recognizable as just
software companies — instead, they bring food to our door, help
us get a taxi, influence outcomes in presidential elections, or act as
a personal trainer.
COMPUTER PROGRAMMING 1 3
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
1. System Programs
These are programs that are needed to keep all the hardware and software
systems running together smoothly. Examples are operating systems like
Linux, Windows, Unix, Solaris, and macOS.
2. Application Programs
These are programs that people use to get their work done. Examples are a
word processor, game programs, and spreadsheets.
3. Compilers
Compilers are responsible for translating computer programs into machine
language. Machine language, on the other hand, is the language that the
computer understands.
COMPUTER PROGRAMMING 1 4
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
Advantages:
Much easy to learn and relatively faster to program in.
Statements naturally look like natural English language, including the
mathematical operators.
Allows the programmer to show how the algorithm solves the problem
in a clearer and more straightforward way.
COMPUTER PROGRAMMING 1 5
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
It is still not very user-friendly, but it is better than working directly with
machine code. However, a CPU (processor) CAN ONLY understand
machine code so anything is written in assembly language still needs to be
translated into machine code for this to work. This is quite a fast process as
there is a direct translation that can occur between the instruction and the
address number.
Machine code is the code executed by the CPU and consists only of binary
digits 0's and 1's. Each type of processor has its own machine code
instruction set, and all programs no matter if they are written in high-level
or assembly languages will have to be translated into machine code
before being executed.
Advantages:
Assembly language is often used in embedded systems such as systems
that control a washing machine, traffic lights, or a robot.
It has features that make it suitable for the following types of
applications:
It gives complete control to the programmer over the system
components, so it can be used to control and manipulate specific
hardware components.
It has very efficient code that can be written for a particular
processor architecture, so will occupy less memory and execute
(run) faster than a compiled/interpreted high-level language.
COMPUTER PROGRAMMING 1 6
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
The terms high-level and low-level are inherently relative; it means that not
all high-level programming languages today will still be high-level shortly.
Year Description
The first device known to carry out calculations was the abacus. It
was invented in Asia but was used in ancient Babylon, China, and
Late Middle Ages
throughout Europe until the late middle ages. The abacus uses a
system of sliding beads on a rack for addition and subtraction.
COMPUTER PROGRAMMING 1 7
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
The first computer-like machine was the Mark I. It was built by IBM
and Harvard University under the leadership of Howard Aiken.
1944
Punched cards were used to feed data into the machine. Mark I
was 52 feet long, weighed 50 tons, and had 750, 000 parts.
The computers that we know today use the design rules given by
John von Neumann. His design included components such as
late 1940s arithmetic logic unit, control unit, memory, and input/output
devices. Neumann's design makes it possible to store the
programming instruction and the data in the same memory space.
Stephen Wozniak and Steven Jobs designed and built the first
1977
Apple computer in the garage.
COMPUTER PROGRAMMING 1 7
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
COMPUTER PROGRAMMING 1 7
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
COMPUTER PROGRAMMING 1 8
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
Flowchart
COMPUTER PROGRAMMING 1 9
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
Note: These are just guidelines for commonly used symbols in creating flowcharts. There are more
flowchart symbols, and you can use any symbols in creating your flowcharts as long as you are
consistent in using them.
Debugging
Debugging is the process of fixing some errors (bugs) in your program.
EXAMPLE PROBLEM 1:
Write an algorithm to find the area of a rectangle.
Pseudocode: Flowchart:
Step 1: Start
Step 2: Get l, b values
Step 3: Calculate A=l*b
Step 4: Display A
Step 5: Stop
EXAMPLE PROBLEM 2:
Write an algorithm for calculating the simple interest of an amount.
Pseudocode: Flowchart:
Step 1: Start
Step 2: Get P, n, r value
Step 3: Calculate SI=(p*n*r)/100
Step 4: Display SI
Step 5: Stop
EXAMPLE PROBLEM 3:
Write an algorithm that will determine if a number is positive or
negative.
Pseudocode: Flowchart:
Step 1: Start
Step 2: Get num
Step 3: Check if(num>0), print "Num is positive."
Step 4: Else, display "Num is negative."
Step 5: Stop
COMPUTER PROGRAMMING 1 11
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
TYPES OF ERRORS
2. Runtime Errors
Compilers are not perfect, and so they cannot catch all errors at compile
time. This is especially true for logic errors, such as infinite loops. This type
of error is called runtime error.
COMPUTER PROGRAMMING 1 12
Module 1: Lesson 1 - Computer Programs, Algorithms, and Flowcharting
APPLICATION
CLOSURE:
Great job! You have finished Lesson 1 of this module. Now, you
are already prepared to move to Lesson 2 of this module.
Congratulations!
COMPUTER PROGRAMMING 1 13
Module 1: Lesson 2
History of Java and Elements of a
Java Program
LEARNING OUTCOMES
INTRODUCTION
ACTIVITY
COMPUTER PROGRAMMING 1 14
Module 1: Lesson 2 - History of Java and Parts of a Java Program
ANALYSIS
ABSTRACTION
HISTORY OF JAVA
COMPUTER PROGRAMMING 1 15
Module 1: Lesson 2 - History of Java and Parts of a Java Program
Uses of Java
COMPUTER PROGRAMMING 1 16
Module 1: Lesson 2 - History of Java and Parts of a Java Program
These computers or chips understand only one thing, which is called machine
language or code. These machine codes run at the CPU level. Therefore, it
would be different machine codes for other models of CPU.
However, you need to worry about the machine code, as programming is all
about the source code. The machine understands this source code and
translates them into machine understandable code, which is an executable
code.
COMPUTER PROGRAMMING 1 17
Module 1: Lesson 2 - History of Java and Parts of a Java Program
Why JVM?
Here are the important reasons of using JVM:
JVM provides a platform-independent way of executing Java source code.
It has numerous libraries, tools, and frameworks.
Once you run a Java program, you can run on any platform and save lots of
time.
JVM comes with JIT (Just-in-Time) compiler that converts Java source code
into low-level machine language. Hence, it runs faster than a regular
application.
COMPUTER PROGRAMMING 1 18
Module 1: Lesson 2 - History of Java and Parts of a Java Program
4. Java FX:
JavaFX is a platform for developing rich internet applications using a
lightweight user-interface API. It user hardware-accelerated graphics and
media engines that help Java take advantage of higher-performance clients
and a modern look-and-feel and high-level APIs for connecting to networked
data sources.
COMPUTER PROGRAMMING 1 19
Module 1: Lesson 2 - History of Java and Parts of a Java Program
It is necessary to know the exact structure of the Java program, and this lesson
contains a detailed description of it. This lesson is essential for you before
proceeding to learn more advanced lessons of Java programming. Here, in this
chapter, you will study the structure of the Java program. Such as how to create a
simple Java program and what its different sections mean. Java program structure
means - the way to write a java program or general format.
COMPUTER PROGRAMMING 1 20
Module 1: Lesson 2 - History of Java and Parts of a Java Program
You have to keep in mind that, Java code is case sensitive. To write a Java
program, you must have to define class first. The name of the class in Java
(which holds the main method) is the name of the Java program, and the same
name will be given in the filename. As mentioned above in the sample program;
The name of the class is "Hello" which the main method is, then this file will be
named "Hello.java".
public static void When the main method is declared public, it means
that it can also be used by code outside of its class, due
to which the main method is declared public.
The word static is used when we want to access a
method without creating its object, as we call the main
method, before creating any class objects.
The word void indicates that a method does not return
a value. main() is declared as void because it does not
return a value.
COMPUTER PROGRAMMING 1 21
Module 1: Lesson 2 - History of Java and Parts of a Java Program
//This is a This is another comment and does not affect the flow
comment. of the program.
C++ Style comments start with // and all the text after
// are treated as comments.
Java Identifiers
Java identifiers are tokens that represent names of variables, methods, classes,
etc. These are case-sensitive which means that the identifier Hello is not the
same as hello.
Identifiers must begin with either a letter, an underscore “_”, or a dollar sign
“$”. Letters may be lower or upper case. Subsequent characters may use
numbers 0 to 9.
Identifiers cannot use Java keywords like class, public, void, etc. We will
discuss more Java keywords later.
COMPUTER PROGRAMMING 1 22
Module 1: Lesson 2 - History of Java and Parts of a Java Program
Java Keywords
Java keywords are also known as reserved words. Keywords are particular words
that act as a key to a code. These are predefined words by Java so they cannot be
used as a variable or object name or class name.
COMPUTER PROGRAMMING 1 23
Module 1: Lesson 2 - History of Java and Parts of a Java Program
Netbeans IDE
Netbeans IDE started as a student project known as Xelfi in the past, is a popular
IDE developed with the goal to create a Delphi-like IDE for Java. First developed in
1996, it has grown into a full-fledged IDE for Enterprise scaled software
development. With its excellent integrated abilities like the connection manager,
integrated Glassfish server, and resource managers, Netbeans IDE makes
development quite easy for novice developers. This article has been created with
the goal to guide every developer on how to make the most out of Netbeans IDE
and its features.
An IDE that knows the syntax of your language can provide visual cues. Keywords,
words that have special meaning like a class in Java, are highlighted with different
colors.
The biggest benefit to using an IDE is that it allows you to code and run Java
programs on your own computer.
1.Let us start with the creation of the first project. To start with the first
project, either navigate to File -> New Project or simply press the New Project
button as described above. It should open up a small window as shown below.
COMPUTER PROGRAMMING 1 24
Module 1: Lesson 2 - History of Java and Parts of a Java Program
With on click of Finish, you should be able to see that your main class is
automatically created. The project shows up in the Projects window and the
MainClass shows up in the editor. A snapshot of how it appears is shown below.
COMPUTER PROGRAMMING 1 25
Module 1: Lesson 2 - History of Java and Parts of a Java Program
APPLICATION
CLOSURE:
Congratulations, in completing this lesson, you may now proceed
to Module Assessment!
COMPUTER PROGRAMMING 1 26
Module
Assessment
Create a Java program that has a class name, Module1Assessment_LastName.
Display the following information by following the given form below. In your code,
you need to add the necessary information and display your output with clarity
and organization of content.
COMPUTER PROGRAMMING 1 27
Module
Summary
For a program to work properly, you must develop correct
logic. Logical errors are much more difficult to locate than
syntax errors.
Developing a program involves problem definition, problem
analysis, algorithm design, and representation (pseudocode or
flowchart), and coding and debugging.
Java was developed by James Gosling with his team in Sun
Microsystems in 1991.
Java is a multi-platform, object-oriented, and network-centric
programming language Java is a general-purpose, class-based,
object-oriented programming language.
Java Platform is a collection of programs that help
programmers to develop and run Java applications efficiently.
Meaning of Java: Java is a multi-platform and network-centric
programming language.
It is mainly used for developing Android Apps and Enterprise
Software.
2009, Oracle Corporation acquired Sun Microsystems and took
ownership of three key Sun software assets: Java, Solaris, and
MySQL.
The best feature of the Java is that it is one of the easiest
programming languages to learn.
Four types of Java Programming language platforms are: 1)
Java Platform, Standard Edition (Java SE) 2) Java Platform,
Enterprise Edition (Java EE) 3) Java Platform, Micro Edition (Java
ME) 4) JavaFX
A computer is an electronic device capable of performing
computations.
The computer only understands electronic signals or binary
signals.
Assembler is an advanced technology that converts source
core to corresponding machine code (110001..) and feeds to
your processor.
COMPUTER PROGRAMMING 1 28
REFERENCES
Farrel, J. (2015). Programming logic and design introductory (8th
ed.). Andover: Cengage Learning.
Goswami. (2016). Computer fundamentals and programming.
Andover: Cengage Learning
Sun Microsystems, Inc. (2015). JEDI introduction to programming
[PDF file]. Retrieved from
https://edu.netbeans.org/contrib/jedi/Intro-to-
Programming1/student-manual.pdf
Pomperada, J.R. (2016). Introduction to java programming.
Hoboken, New Jersey: Wiley
COMPUTER PROGRAMMING 1 29