Description:
Use static methods for utility calculations.
Use static methods for utility calculations.
Java Code
public class MathUtils {
static int square(int n) { return n * n; }
static int cube(int n) { return n * n * n; }
public static void main(String[] args) {
System.out.println("Square of 7: " + square(7));
System.out.println("Cube of 3: " + cube(3));
}
}
Expected Output
Square of 7: 49
Cube of 3: 27