Programming Basics &
Algorithmic Thinking

Master the core of Java, from logical steps to machine execution.

Algorithm Discovery

Can you guide the robot to its morning coffee?

Command Bank

Add steps to your algorithm.

Step-by-Step Sequence0/8

Algorithm is empty.
Select commands to start.

What is an Algorithm?

A precise, step-by-step procedure for solving a specific task.

1
Step-by-step
2
Finite
3
Precise
6:00 AM
01
Alarm Rings
02
Snooze?
03
Get Out of Bed
04
Start Your Day
05

When Languages Don't Match

A translator can turn unfamiliar signals into a shared language.

The Compiler

The Compiler translates human Java code into machine instructions.

High Strictness

Unlike humans, a compiler cannot "guess" your meaning. Every semicolon, bracket, and quote counts.
.javaHUMAN READABLE
Compiler

01101001

11001110

10101011

00000001

11110000

10101010

01010101

11001100

10001000

01110111

.classBYTECODE

Standard Framework

Every Java journey starts with a class and a main method.

HelloWorld.java
java

"Think of it as the mandatory doorway to your code."

String Literals

The 'Containers' of Messages

"Hello World"
String Container
This is the Data (Text)

The Container Rule

Quotes tell the compiler: "Everything inside is just text, don't try to run it!"

Literals

Directly typed text in code. What you see inside the quotes is what gets printed.

Output Mechanics

Communicating with the Machine Console

print = Stay on line

println = Message + Enter

Comparison.java
java
Console Output
Hello World
Comparison.java
java
Console Output
Hello World

Quick Challenge

Predict the Output

Quiz.java
java

Escape Sequences

A backslash changes the meaning of special characters in a string.

\n
New Line
\"
Double Quote
\\
Backslash
Escape.java
java
Console Output
He said "Hi!"

Escaping Quiz

Predict the Visual Result

Quiz.java
java

Arithmetic Operators

The Building Blocks of Java Calculation

+
Addition
5 + 2 = 7
-
Subtraction
5 - 2 = 3
*
Multiplication
5 * 2 = 10
/
Division
5 / 2 = 2
Integer Division!
%
Modulo
5 % 2 = 1
Remainder

Precedence

1

Grouping

() are always evaluated first.
2

Powerhouse

*, /, and % have higher priority.
3

Standard

+ and - are performed last.
Precedence Rule
7 - (6 + 5) % 4

Press Next to evaluate one rule at a time.

0 / 3
/
2

Integer Division Playground

Truncation Trap

In Java, dividing two integers always results in an integer.

Integer Division

Java intentionally truncates (throws away) the decimal part. It never rounds up, even if the result is 2.99!

Calculation Quiz

Apply precedence and truncation

What is the result of:
10 / 4 + 7 % 3 * 5

Documentation

The machine simply skips them entirely.

//Single-line
/*...*/Multi-line
/**...*/Doc Comment
CommentDemo.java
java

Course Summary

Key takeaways from today's session

Standard Framework

Every program needs a class and a main method to run.

Output Mechanics

print stays on the same line, while println adds a new line after.

Escape Sequences

Use \n for new lines and \" to print double quotes inside strings.

Integer Division

Dividing two ints always truncates (drops the decimal). example: 5 / 2 = 2.

After-Class
Assignment

Character Challenge

  • 1. Write a Java program that prints your favorite quote.
  • 2. Wrap the quote in literal double quotes.
  • 3. Print the full line exactly as you want it to appear.

Calculate 5 Expressions

  • 1. (8 + 2) / 3 * 2
  • 2. 9 / 2 - 5 % 3
  • 3. (7 + 4) / 3 + 1
  • 4. 6 * 3 / 5 + 1
  • 5. (9 - 1) % 5 / 2