Multiply by 3
Programming Basics · Java
TASK
Problem
Given an integer `n`, print `n * 3`. Use standard input and print exactly the result required for `Multiply by 3`.
EXAMPLE
Example
6
18
LIMITS
Constraints
-10^8 ≤ n ≤ 10^8
LEARN
Theory for this problem
+
The core idea of **Multiply by 3** is to model the requested operation directly: Given an integer `n`, print `n * 3`. Use standard input and print exactly the result required for `Multiply by 3`. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Multiply by 3** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Multiply by 3
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int result = n * 3;
System.out.println(result);
}
}