Concept Flow - Why input and output are required
Start Program
Request Input from User
Process Input
Generate Output
End Program
The program starts by asking for input, processes it, then shows output before ending.
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); System.out.println("You entered: " + num); sc.close(); } }
| Step | Action | Input/Variable | Output | Explanation |
|---|---|---|---|---|
| 1 | Start program | - | - | Program begins execution |
| 2 | Request input | User types 5 | - | Program waits for user input |
| 3 | Read input | num = 5 | - | Input stored in variable num |
| 4 | Print output | - | You entered: 5 | Program shows the input back to user |
| 5 | End program | - | - | Program finishes |
| Variable | Start | After Input | Final |
|---|---|---|---|
| num | undefined | 5 | 5 |
Input and output let programs interact with users. Input collects data from the user. Output shows results or messages. Without input, program can't get info. Without output, user can't see results.