-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathtable.java
33 lines (30 loc) · 827 Bytes
/
table.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Write a Java program that takes two user input integers m and n and prints the multiplication table from 1 to n for the
* number m. The program should use nested for loops to generate the table.
*
* Sample Input:
* --------------------
* 3 5
*
* Sample Output:
* --------------------
* 3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
* Explanation:
--------------------
The input integers are m=3 and n=5. The program generates the multiplication table for 3 from 1 to 5.
*/
import java.util.*;
public class table {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k = sc.nextInt();
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
System.out.println(k+" x "+i+" = "+k*i);
}
}
}