A tiny collection of beginner Java programs that cover the essentials: arithmetic, logic, loops, and arrays.
All programs are self-contained, compile withjavac <File>.java
, and run via command-line arguments where needed.
# Compile any file
javac <File>.java
# Run (examples)
java Sum
java OddEven 17
java SimpleInterest 2000 5 3
| # | File | Purpose | How to Run |
|----|---------------------|------------------------------------------------------------|--------------------------------|
| 1 | `sum.java` | Adds two hard-coded integers and prints the result. | `java sum` |
| 2 | `dynamic_int.java` | Calculates simple interest from CLI args: `P R T`. | `java dynamic_int 1000 5 2` |
| 3 | `swap.java` | Swaps two hard-coded integers using a temp variable. | `java swap` |
| 4 | `area_circle.java` | Displays area of a circle (hard-coded radius). | `java area_circle` |
| 5 | `dynamic_odd_even.java` | Tells if the CLI arg is odd or even. | `java dynamic_odd_even 42` |
| 6 | `value.java` | Compares two CLI numbers with an else-if ladder. | `java value 12 9` |
| 7 | `marksheet.java` | Computes total, average, and grade for 3 CLI marks. | `java marksheet 85 92 78` |
| 8 | `minimum.java` | Finds the smallest of 3 CLI numbers. | `java minimum 12 7 25` |
| 9 | `int.java` | Prints square of the larger CLI arg or cube of the smaller.| `java int 5 3` |
| 10 | `table.java` | Prints the multiplication table (1–10) of the CLI arg. | `java table 7` |
| 11 | `Fibonacci.java` | Lists Fibonacci numbers up to the CLI limit. | `java Fibonacci 50` |
| 12 | `factorial.java` | Computes factorial of the CLI arg. | `java factorial 5` |
Basic-Java/
Fibonacci.java
Create area_circle.java
dynamic_int.java
dynamic_odd_even.java
factorial.java
int.java
marksheet.java
minimum.java
odd_even.java
sum.java
Create sum.java
swap.java
table.java
value.java
readme.md <- You are here