Command Palette

Search for a command to run...

Back to the lesson: Topic 0.1 — What a Program Is
Core Java · Example 2 of 3

Input, processing, output

The text after // is a comment: a note for humans that Java ignores. The % sign gives the remainder of a division.

A program is a list of exact instructions that a computer follows one after another, very fast and without ever guessing what you meant. A programming language like Java lets humans write those instructions in words, and a tool translates them into the numbers the computer's chip understands.

Change the code and press Run (Ctrl+Enter). Try to predict the output first, then break it on purpose and read the error. Your edits are saved and match the lesson page.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a program that prints your morning routine in four numbered steps.

02

Write a program that stores the price of one pencil (5) and the number of pencils (7), then prints the total cost.

03

Write a program that starts with 100 points, loses 30, gains 45, and prints the points after each change.

Explain it without notes

01

Explain what a program is to someone who has never used a computer.

02

Why can't we write programs directly in the language a CPU understands?

03

What is the difference between an error the compiler shows you and a logic bug?

04

Describe input, processing and output for a calculator app.

Input, processing, output
Sign in to run this example in your browser.

Expected output

Cookies: 14
Friends: 4
Each friend gets: 3
Left in the jar: 2