JAVA
Free Section Starter Challenge
25 min
3. Modular Methods & Parameter Passing
Overview: Define reusable static and instance methods with typed return values.
Concept & Syntax Guide
Methods encapsulate reusable algorithms. Declaring `public static double applyTax(double price)` enforces strict input and output contracts.
Hands-On Practice Exercise
Build a Tax Calculation Method
Write a method `public static int addGST(int price)` that adds 18% to the price and returns the rounded integer.
Target Output:
Price with GST: 1180
Need a hint? Click here to reveal
Hint: Check syntax carefully and make sure your code contains:
Price with GST: 1180
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10