1
Assignment 1 · print / println

Introduction To Programming (Java)

Create a tree using print and println methods in Java — no user input required.

🎯 Skill: Composing output character by character with print vs println
Tree.java
// Each row = one println() call
System.out.println(" * ");
System.out.println(" *** ");
System.out.println(" ***** ");
System.out.println(" ******* ");
System.out.println(" | | ");

// print() stays on same line
// println() moves to next line
Console Output — builds live
2
Assignment 2 · arithmetic operators

Variables and Assignments

Get user input, store values in variables, perform arithmetic operations, and display the results.

🎯 Skill: Scanner input → variable storage → arithmetic → output
Arithmetic.java
Scanner sc = new Scanner(System.in);

double a = sc.nextDouble();
double b = sc.nextDouble();

System.out.println(a + b); // sum
System.out.println(a - b); // diff
System.out.println(a * b); // product
System.out.println(a / b); // quotient
Live Calculator
a =
b =
a + b16.0
a - b8.0
a * b48.0
a / b3.0
3
Assignment 3 · modulus operator

Console Input and Output

Work with the modulus operator to calculate and display output — understanding remainders and integer division.

🎯 Skill: Using % to extract digits, convert units, detect even/odd
Modulus.java
int seconds = 137;

// Integer division → minutes
int mins = seconds / 60;

// Modulus → leftover seconds
int secs = seconds % 60;

// Even or odd?
boolean even = (seconds % 2 == 0);
Modulus Explorer
seconds = 137
/ 60 (minutes) 2
% 60 (remainder) 17
% 2 == 0 (even?) false
2 min 17 sec
4
Assignment 4 · if / switch

Branches

Write programs using if-statements and switch statements to produce output based on certain criteria.

🎯 Skill: Routing program logic based on conditions and matched values
Branches.java
int day = 3;

switch (day) {
case 1: System.out.println("Monday"); break;
case 2: System.out.println("Tuesday"); break;
case 3: System.out.println("Wednesday");break;
case 4: System.out.println("Thursday"); break;
case 5: System.out.println("Friday"); break;
default: System.out.println("Weekend");
}
Switch Router — drag to test
day = 3
case 1 → Monday
case 2 → Tuesday
case 3 → Wednesday ✓
case 4 → Thursday
case 5 → Friday
default → Weekend
5
Assignment 5 · while / for loops

Loops

Use if-statements, switch statements, while and for loops together to produce output based on combined criteria.

🎯 Skill: Combining iteration with conditional logic inside a loop body
Loops.java
// Loop + condition combined
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
System.out.println(i + " is EVEN");
} else {
System.out.println(i + " is ODD");
}
}
Loop Output — how many iterations?
limit = 10
6
Assignment 6 · methods + statistics

User Defined Methods

Write a collection of methods that perform statistical analysis on a series of numbers — each operation is its own method.

🎯 Skill: Breaking a problem into separate methods, passing data, returning results
Stats.java
static double getSum(int[] arr) {
double sum = 0;
for (int v : arr) sum += v;
return sum;
}

static double getAverage(int[] arr) {
return getSum(arr) / arr.length;
}

static int getMax(int[] arr) { ... }
static int getMin(int[] arr) { ... }
Enter numbers (comma-separated)
getSum()391
getAverage()55.9
getMax()95
getMin()15
count7
7
Assignment 7 · arrays + grade logic

One Dimensional Arrays

Use an array with grade-related methods to build a program that stores, processes, and reports student scores.

🎯 Skill: Storing data in arrays, iterating with a loop, calling methods to analyze
GradeBook.java
int[] grades = {88,72,95,61,84};

for (int i = 0; i < grades.length; i++) {
if (grades[i] >= 90) print("A");
else if (grades[i] >= 80) print("B");
else if (grades[i] >= 70) print("C");
else print("F");
}
Gradebook — click a score cell
88
[0]
72
[1]
95
[2]
61
[3]
84
[4]
grades[0] = 88 → letter grade
B
Class avg80.0
Highest95 (A)
Lowest61 (F)
8
Assignment 8 · class design + OOP

Objects and Classes

Create a Circle class, then instantiate multiple circle objects and call methods to compute area and circumference.

🎯 Skill: Class blueprint → constructor → instance methods → multiple objects
Circle.java
public class Circle {
private double radius;

public Circle(double r) {
radius = r;
}

public double getArea() {
return Math.PI * radius * radius;
}

public double getCircumference() {
return 2 * Math.PI * radius;
}
}
Live Circle — drag radius
r
radius 5.0
getArea() 78.54
getCircumference() 31.42