Introduction to Computer Programming
Seoul National University of Science and Technology
Information Technology Management
Lecture slides index
March 24, 2025
Prof. Josue Obregon
Tel: 02-970-7291
Office: Changhak Hall (3), Room 334-1
Office Hours: Monday 14:00 – 17:00 (but come anytime!)
Home-page: https://eis.seoultech.ac.kr/
Email: jobregon@seoultech.ac.kr
Publications: Google Scholar Profile
Learning to write programs stretches your mind, and helps you think better, creates a way of thinking about things that I think is helpful in all domains.
— Bill Gates, Microsoft co-founder
Assesment | Points |
---|---|
Assignments | 15% |
Term project | 15% |
Midterm | 30% |
Final exam | 40% |
Total | 100% |
SeoulTech Grades | Marks (100) | NU Grades |
---|---|---|
A+ (4.5) A0 (4.0) |
above 70 | First |
B+ (3.5) B0 (3.0) |
above 60 | Upper Second |
C+ (2.5) C0 (2.0) |
above 50 | Lower Second |
D+ (1.5) D0 (1.0) |
above 40 | Third |
F (0.0) | under 40 | Fail |
It involves the ability to formulate problems, think creatively about solutions, and express solutions clearly and accurately.
Broad goals of this module:
A programming language is a formal system used to communicate with computers, allowing humans to write instructions that a computer can understand and execute (i.e., to write, compile, and execute programs).
A program is a sequence of instructions that specifies how to perform a computation on computer hardware.
Programming can be seen as the process of breaking down a large, complex task into smaller and smaller subtasks.
Low-level languages
High-level languages
How interpreted languages are executed
The process of compiling and running a Java program
Modern programming is practically always done in an IDE (integrated development environment).
An IDE contains a set of useful tools for the programmer.
It does not create the program by itself, but it can give hints about common mistakes in the code, and help the programmer understand the structure of the program.
But, for the first weeks, we are going to use a much simpler approach.
In order to understand better how Java programs are written, compiled and executed, we are going to do it manually.
The following steps must be followed:
javac
)java
)java -version
to check the installed Java version.javac -version
to ensure the compiler is installed.JAVA_HOME
Variable (link)C:\Program Files\Java\jdk1.x.x_xx
).JAVA_HOME
.
JAVA_HOME
.%JAVA_HOME%\bin
to the list of paths if it’s not already included.~/.bash_profile
in any text editor.Insert the following line to dynamically set JAVA_HOME
:
Save and close the file.
Open a Terminal and run:
Check the value of the JAVA_HOME
variable:
The output should display the path to your JDK installation.
Create a folder structure that you are going to use for our course, for example comlang/week1/01_helloworld/
.
Inside that folder, create a file named HelloWorld.java
with the following code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Computer Language ITM!");
}
}
Source Code is the written code composed of statements and expressions read sequentially.
Java offers many built-in commands to simplify development.
Example:
This command instructs the computer to print the provided string.
Note the semicolon ; at the end, which marks the end of a statement.
These basics form the foundation for all Java programming.
public class Example {
public static void main(String[] args) {
// The statements used by the program are placed here
System.out.println("Welcome to the course - you will learn to program!");
}
}
The print command System.out.println("Hello world");
prints the text “Hello world”.
Output
You can print any text you want with the command, as long as the command System.out.println("arbitrary text");
— i.e., System
dot out
dot println
open parenthesis (
“the text” close parenthesis )
and semicolon ;
remains unchanged.
In Java, our programs have to include some boilerplate code1 to work.
This boilerplate, an example of which is shown below, for example tells the computer what your program is called.
Below, the name of the program is Example
. This name has to correspond to the name of the file that contains the source code (e.g. Example.java
).
Execution of the program starts from the line that follows public static void main(string[] args) {
, and ends at the closing curly bracket }
.
We’ll learn what the terms public class
and public static void
mean later on.
In this example, System.out.println("Text to be printed")
is the only command to be executed.
Text to be printed
The examples in our slides will not always show the template, but you can assume that your program file always needs one.
As such, the examples might be as short as a single line, such as the example below that illustrates the print command.
Here’s the second programming exercise of this course.The exercise template has the following boilerplate code:
The line “// Write your program here” is a line comment, and the computer will ignore it when executing the program.
Add a new line below the line comment that prints the string “Ada Lovelace” and run the program. The output of the program should be:
Running the program is straightforward, but a lot is happenings behind the scenes. Can you explain it step by step?
Programs are constructed command-by-command, where each command is placed on a new line.
In the example below, the command System.out.println
appears twice, which means that two print commands are being executed in the program.
public class HelloWorldMultiLine {
public static void main(String[] args) {
System.out.println("Hello world!");
System.out.println("... and the universe!");
}
}
printin
instead of println
The exercise comes with the following template:
public class OnceUponATime {
public static void main(String[] args) {
// Write your program here
}
}
Modify the program so that it will print the following text. Use three System.out.println
-commands for printing.
()
that follow the command.
Hi
as a parameter to the System.out.println
command is done like this: System.out.println("Hi")
.;
.Output
Below is an example of a program where both are used.
public class Comments {
public static void main(String[] args) {
// Printing
System.out.println("Text to print");
System.out.println("More text to print!");
/* Next:
- more on printing
- more practice
- variables
- ...
*/
System.out.println("Some other text to print");
// System.out.println("Trying stuff out")
}
}
The last line of the example shows a particularly handy use-case for comments. Code that has been written does not need to be deleted to try out something else.
The exercise comes with the following template:
Edit the program so that it will print the following text:
Computer Language
Comments (I)
Source code can be commented to clarify it or to add notes. There are two ways to do this.
Single-line comments are marked with two slashes
//
. Everything following them on the same line is interpreted as a comment.Multi-line comments are marked with a slash and an asterisk
/*
, and closed with an asterisk followed by a slash*/
. Everything between them is interpreted as a comment.