Java program to print tables
Java program that takes a number as input and prints the tables for that number
import java.util.Scanner;
public class Tables {
public static void main(String[] args) {
System.out.println("Please enter a number: ");
Scanner in = new Scanner(System.in);
int input = in.nextInt();
in.close();
for (int i = 1; i <= 10; i++) {
System.out.println(input + " * " + i + " = " + input * +i);
}
}
}
Output:
Please enter a number:
9
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
9 * 10 = 90