Assignment: Module 03- Part 02
![]() |
Assignment: Module 03- Part 02 |
Write a class MultiplicationtTable to accept a number to find the table calculation of it till 10.
Input:
Enter the no. 3
Output:
1*3=3
2*3=6
3*3=9
4*3=12
5*3=15
6*3=18
7*3=21
8*3=24
9*3=27
10*3=30
import java.util.Scanner;
public class MultiplicationTable {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number: ");
int num = sc.nextInt();
for (int i = 1; i <= 10; i++) {
System.out.println(i + " * " + num + " = " + (i * num));
}
}
}
And here is a sample output for the input 3:
Enter the number: 3
1 * 3 = 3
2 * 3 = 6
3 * 3 = 9
4 * 3 = 12
5 * 3 = 15
6 * 3 = 18
7 * 3 = 21
8 * 3 = 24
9 * 3 = 27
10 * 3 = 30