Beginner level · Module 2 of 5 · 11 guided hours
Decisions, Loops and Methods in Java
Control the flow of a program with conditions and loops, read input with Scanner, and organise code into reusable methods.
Learning objectives
- Use if/else and switch to make decisions
- Repeat work with for, while and do-while loops
- Write methods with parameters and return values
Topics
- comparison and logical operators
- if/else and switch
- for, while, do-while
- Scanner input
- methods, parameters and return
- method overloading
Lessons
-
Lesson 1 Making Decisions with if and switch
Use comparisons, logical operators, if/else chains and switch to choose what a program does.
boolean expression&& and ||else ifswitch expression
-
Lesson 2 Loops and Reading Input
Repeat work with for, while and do-while loops, and read user input safely with Scanner.
for loopwhile and do-whilesentinel valueScanner
-
Lesson 3 Writing Methods
Break programs into methods with parameters and return values, and understand variable scope.
method signaturereturn typeparametersscopeoverloading
Practical activity
Build a school fees checker that reads student payments, decides each student's status (paid, partly paid, not paid) and totals the outstanding balance, using one method per task.
Expected outcomes
- Programs that respond to input and repeat work safely
- Code split into small, named methods
Assessment
Practical test: complete a partly written program by adding a loop, a decision and two methods; marked with a provided set of test inputs.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.