Views: 307
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
On By
FastFoodCoding
Top Tutorials
492.5K
32K
21.8K
18.7K
18.7K
6.7K
6.6K
4.9K
3.3K
3.1K
Top Questions
18.7K
14.5K
8.3K
6.6K
6.2K
5.7K
4.8K
4.8K
4.3K
3.9K
Top Articles
1.9K
1.6K
947
Top Blogs
796
778
54
Top News
752
683
670
397
383
381