Lesson overview

Build Java foundations through one grade calculator

Follow the modules in order. Each task adds a practical piece to the final Student Grade Calculator in Java.

Topic 1

What is Java?

Java is a programming language. You write instructions, Java prepares them, and the program can run on machines that have the Java Virtual Machine.

Java code->Compiler->Bytecode->JVM->Program runs

Java as an application language

Java is used to build school result systems, banking apps, Android apps, backend services and enterprise tools. It is not the same as JavaScript. JavaScript mainly runs in browsers; Java is commonly used for larger application systems.

System.out.println("Java is ready");

How to read this code: System.out.println tells Java to print a message. The text inside quotes is the message.

Why this matters: The first step in programming is learning how to make the computer show a clear result.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
JavaA programming languageUsed to build applicationsclass Main
JavaScriptA different web languageUsed mostly for browser interactiondocument.querySelector()
printShow text on screenHelps see program outputSystem.out.println("Hi");

Quick exercise

Name one real-life system that could be built with Java.

Mini-project task

Write one sentence explaining what your Student Grade Calculator should do.

Compiler, bytecode and JVM in simple terms

Java code is prepared by a compiler. The compiler creates bytecode. The JVM reads that bytecode and runs the program. "Write once, run anywhere" means Java code can run on different systems when the right Java setup is available.

// You write Java code
// Java compiles it
// The JVM runs it

How to understand this example: The lines begin with //, so they are comments. Comments explain code but do not run.

Why this matters: Java has a clear preparation step before the program runs, which is different from writing quick browser scripts.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
compilerA tool that prepares codeTurns Java code into bytecodejavac Main.java
bytecodePrepared Java instructionsCan be run by the JVMMain.class
JVMJava Virtual MachineRuns Java bytecodejava Main

Quick exercise

What reads Java bytecode to run a program?

Mini-project task

Add a short comment at the top of your project saying what the calculator will do.

Topic checkpoint

You can explain Java, JavaScript, compiler, bytecode and JVM in beginner-friendly words.

Topic 2

Java program structure

A Java program has a class and a main method where the program starts.

class, main method, braces and semicolons

A class is a container for Java code. The main method is the starting point. Braces group code together. Semicolons end many Java instructions.

public class Main {
  public static void main(String[] args) {
    System.out.println("Welcome to TechPathReady");
  }
}

How to read this code: public class Main starts the class. main is where Java begins. The print line shows the welcome message. The braces show what belongs inside the class and method.

Why this matters: If the structure is wrong, Java will not know where the program begins.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
classA container for codeJava programs are organised in classesclass Main
main methodThe starting pointJava starts running heremain(String[] args)
bracesCode group markersShow what belongs together{ }
semicolonInstruction endingEnds many Java statementsint score = 80;

Quick exercise

Which method is the starting point of a Java program?

Mini-project task

Create the starting Main program for the grade calculator.

System.out.println()

System.out.println() prints a line of text. It is useful when learning because it shows what your program is doing.

System.out.println("Student Grade Calculator");

How to read this code: Java prints the exact words inside the quote marks and then moves to the next line.

Why this matters: Clear output helps users understand the result of your calculator.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
outputWhat the program showsHelps users see resultsSystem.out.println(score);
StringTextUsed for messages"Hello"
printlnPrint lineShows text and starts a new lineprintln("Done")

Quick exercise

Write a print line that says "Calculator ready".

Mini-project task

Print a title at the start of your grade calculator.

Topic checkpoint

You can create a starter Java program and print a clear message.

Topic 3

Variables and data types

Java variables are labelled boxes. Java is strongly typed, so each box must have a type.

int, double, boolean, char and String

An int stores a whole number. A double stores a decimal. A boolean stores true or false. A char stores one character. A String stores text.

String studentName = "Aisha";
int mathsMark = 78;
int scienceMark = 84;
double average = 81.0;
boolean passed = true;
char grade = 'A';

How to read this code: Each line creates a labelled box. The type comes first, then the variable name, then the value.

Why this matters: The calculator needs to remember names, marks, averages, pass status and grade labels.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
variableA labelled box that stores informationSo the program can remember a valueint score = 80;
intA whole number typeUsed for marks and countsint age = 15;
doubleA decimal number typeUsed when answers may include decimalsdouble average = 72.5;
StringText valueUsed for names and messagesString name = "Courtney";

Quick exercise

Which type would you use for a student name?

Mini-project task

Store the student name and three subject marks.

Topic checkpoint

Your grade calculator can now store the first values it needs.

Topic 4

Operators and expressions

Operators combine values to create new results.

Marks->Total->Average->Result

Arithmetic, comparison, logical and assignment operators

Arithmetic operators calculate values. Comparison operators check values. Logical operators combine checks. The assignment operator stores a value.

int total = mathsMark + scienceMark;
double average = total / 2.0;
boolean strongAverage = average >= 80;
boolean ready = average >= 60 && passed;

How to read this code: Java adds marks, divides by 2.0 to keep decimals, checks whether the average is strong, then combines two true/false checks.

Why this matters: Grades depend on calculations and comparisons.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
operatorA symbol that does workCalculates or compares values+, >=
assignmentStore a valuePuts data into a variabletotal = 90;
comparisonA true/false checkUsed for decisionsaverage >= 60
logical operatorCombines checksUsed when two rules matter&&

Quick exercise

Why does the example divide by 2.0 instead of 2?

Mini-project task

Calculate total and average mark for your grade calculator.

Topic checkpoint

Your calculator can now calculate a total and average.

Topic 5

Conditions

Conditions let Java choose a path based on data.

Average mark->Check grade->Print feedback

if, else if and else

Use if for the first check, else if for extra checks and else when no earlier check matched.

String gradeMessage;

if (average >= 80) {
  gradeMessage = "A - Strong";
} else if (average >= 60) {
  gradeMessage = "B - Building";
} else if (average >= 40) {
  gradeMessage = "C - Needs practice";
} else {
  gradeMessage = "Needs focused revision";
}

How to read this code: Java checks the top condition first. If it is false, Java moves down until it finds a match.

Why this matters: A grade calculator needs different feedback for different average marks.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
ifFirst decision checkStarts a choiceif (score >= 60)
else ifAnother decision checkAdds more bandselse if (score >= 40)
elseFallback pathRuns if nothing matchedelse { ... }
grade bandA mark rangeTurns numbers into feedbackA - Strong

Quick exercise

What message should an average of 55 print?

Mini-project task

Print a grade message based on the student's average.

Topic checkpoint

Your calculator can now turn a number into feedback.

Topic 6

Loops

Loops repeat work without copying the same line again and again.

Start->Check mark->Add to total->Repeat->Finish

for loop, while loop and enhanced for loop

A for loop is useful when you know how many times to repeat. A while loop repeats while a condition is true. An enhanced for loop reads each item in a list or array.

int[] marks = {78, 84, 69};
int total = 0;

for (int mark : marks) {
  total += mark;
}

How to read this code: int mark : marks means "take each mark from the marks array one at a time".

Why this matters: A grade calculator should handle several marks without manually adding every subject line.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
loopRepeat a taskAvoids copied codefor (...)
for loopRepeat a set number of timesUseful for arraysfor (int mark : marks)
while loopRepeat while trueUseful when stopping depends on a conditionwhile (count < 3)
infinite loopA loop that never stopsCan freeze a programwhile (true)

Quick exercise

Which loop reads each mark in the example?

Mini-project task

Loop through marks to calculate the total.

Topic checkpoint

Your calculator can process several marks in a clean repeatable way.

Topic 7

Arrays

An array stores several values of the same type in one variable.

0 781 842 69

Index positions, length and marks

Arrays start at index 0. The length property tells you how many items are in the array.

int[] marks = {78, 84, 69};
System.out.println(marks[0]);
System.out.println(marks.length);

How to read this code: marks[0] gets the first mark. marks.length counts how many marks exist.

Why this matters: The grade calculator can store all subject marks together.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
arrayA list of same-type valuesStores several marks togetherint[] marks
indexItem positionFinds one valuemarks[0]
lengthNumber of itemsHelps calculate averagemarks.length

Quick exercise

What index gets the first value in a Java array?

Mini-project task

Store subject marks in an array.

Topic checkpoint

Your calculator can store multiple marks in one organised structure.

Topic 8

Methods

Methods are named blocks of reusable code.

Input marks->Method->Average or grade

Method declaration, parameters, return values and void

A parameter is information a method receives. A return value is what the method gives back. A void method does work but does not give back a value.

public static double calculateAverage(int[] marks) {
  int total = 0;

  for (int mark : marks) {
    total += mark;
  }

  return total / (double) marks.length;
}

How to read this code: The method receives an array of marks, adds them, then returns the average as a decimal.

Why this matters: Methods keep the final project easier to read and reuse.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
methodA reusable code blockKeeps logic organisedcalculateAverage()
parameterInput to a methodLets method use outside dataint[] marks
returnGive a value backProduces a resultreturn average;
voidNo return valueUsed for actions like printingvoid printReport()

Quick exercise

What does this method return?

Mini-project task

Create a method that returns the average or grade.

Topic checkpoint

Your calculator can separate calculation logic into reusable methods.

Topic 9

Classes, objects and input

Classes model real things. Input lets the user type values.

Class as blueprint, object as real item

A class is like a blueprint. An object is one real item made from that blueprint. Fields store data inside the object. A constructor sets starting values.

Student class blueprint->student object card
class Student {
  String name;
  int[] marks;

  Student(String name, int[] marks) {
    this.name = name;
    this.marks = marks;
  }
}

How to read this code: The Student class stores a name and marks. The constructor fills those fields when a new student is created.

Why this matters: A real grade system needs to keep each student's information together.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
classBlueprintDefines what an object hasclass Student
objectReal item from a classStores one student's datanew Student(...)
fieldVariable inside a classStores object dataString name;
constructorSetup methodGives object starting valuesStudent(...)

Quick exercise

Is Student the blueprint or the object?

Mini-project task

Create a simple Student object.

Basic input and output with Scanner

Input is information typed by the user. Scanner can read typed text and numbers. Output is what the program prints back.

import java.util.Scanner;

Scanner scanner = new Scanner(System.in);

System.out.print("Enter student name: ");
String name = scanner.nextLine();

System.out.print("Enter maths mark: ");
int mathsMark = scanner.nextInt();

How to read this code: Java imports Scanner, creates a scanner connected to keyboard input, asks questions, then stores the user's answers.

Why this matters: The grade calculator becomes more useful when the user can type their own marks.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
ScannerJava input helperReads keyboard inputnew Scanner(System.in)
nextLineRead a line of textUsed for namesscanner.nextLine()
nextIntRead a whole numberUsed for marksscanner.nextInt()
inputTyped informationMakes program interactive80

Quick exercise

Which Scanner method reads a whole number?

Mini-project task

Allow the user to type name and marks.

Common beginner Java mistakes

Java is strict. Small typing differences can stop a program from compiling. This is normal while learning.

// Broken ideas to spot:
int score = 80
if (score = 80) {
  System.out.println("Check");
}

How to read this code: The first line is missing a semicolon. The condition uses = instead of ==.

Why this matters: Debugging is part of programming. Learning common mistakes makes errors less frustrating.

Key words for this subtopic
Key wordSimple meaningWhy we use itTiny example
semicolonStatement endingJava expects it oftenint score = 80;
case-sensitiveCapitals matterString and string differString name
==Compare equalityChecks if values matchscore == 80
integer divisionWhole-number divisionCan remove decimals5 / 2

Quick exercise

Find two mistakes in the broken snippet.

Mini-project task

Debug a broken grade calculator snippet before writing the final version.

Topic checkpoint

You can model a student, read input and spot common Java mistakes.

Final mini project

Student Grade Calculator in Java

This project combines class structure, main method, variables, data types, operators, conditions, loops, arrays, methods, objects/classes and simple input/output.

import java.util.Scanner;

class Student {
  String name;
  int[] marks;

  Student(String name, int[] marks) {
    this.name = name;
    this.marks = marks;
  }
}

public class Main {
  public static double calculateAverage(int[] marks) {
    int total = 0;

    for (int mark : marks) {
      total += mark;
    }

    return total / (double) marks.length;
  }

  public static String getGrade(double average) {
    if (average >= 80) {
      return "A - Strong";
    } else if (average >= 60) {
      return "B - Building";
    } else if (average >= 40) {
      return "C - Needs practice";
    } else {
      return "Needs focused revision";
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.println("Student Grade Calculator");
    System.out.print("Enter student name: ");
    String name = scanner.nextLine();

    int[] marks = new int[3];

    System.out.print("Enter maths mark: ");
    marks[0] = scanner.nextInt();

    System.out.print("Enter science mark: ");
    marks[1] = scanner.nextInt();

    System.out.print("Enter computing mark: ");
    marks[2] = scanner.nextInt();

    Student student = new Student(name, marks);
    double average = calculateAverage(student.marks);
    String grade = getGrade(average);

    System.out.println();
    System.out.println("Student: " + student.name);
    System.out.println("Average mark: " + average);
    System.out.println("Grade: " + grade);
  }
}

How it works step by step

The program imports Scanner, defines a Student blueprint, asks for a name and marks, stores marks in an array, calculates the average with a method, chooses a grade with conditions and prints a report.

Example output

Student: Aisha
Average mark: 77.0
Grade: B - Building

Upgrade ideas

  • Add more subjects
  • Store multiple students
  • Use arrays of objects
  • Add attendance score
  • Add a menu
  • Save results later in a future advanced version

Next step

Connect Java to your career roadmap

Java is useful for object-oriented programming, backend systems and enterprise-style software. Continue into the Career Path Guide when you want role-based readiness practice.