Problem: 5
Q.write a java program print a table of 2.
import java.util.Scanner;
public class Multiples {
public static void main(String[] args) {
// Create a Scanner object for user input
Scanner scanner = new Scanner(System.in);
// Input: Read a single integer
System.out.print("");
int N = scanner.nextInt();
for (int i = 1; i <= 10; i++) {
int result = N * i;
System.out.println(N + " x " + i + " = " + result);
}
// Close the scanner
scanner.close();
}
}
Output: