-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFor_Loop.java
More file actions
32 lines (24 loc) · 1.04 KB
/
For_Loop.java
File metadata and controls
32 lines (24 loc) · 1.04 KB
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
/**
* Program: For Loop Demo
* Description: A Java program to demonstrate the 'for' loop by printing a multiplication table.
* Author: Amey Thakur
* Reference: https://github.com/Amey-Thakur/OOPM-JAVA-LAB
*/
import java.util.Scanner;
public class For_Loop {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("---------------------------------------------");
System.out.println(" For Loop Demo (Multiplication Table)");
System.out.println("---------------------------------------------");
System.out.print("Enter the number whose table you want to view: ");
int num = scanner.nextInt();
System.out.println("The table for " + num + " is:");
// Loop to generate table up to 10 times
for (int i = 1; i <= 10; i++) {
System.out.println(num + " X " + i + " = " + (num * i));
}
System.out.println("---------------------------------------------");
scanner.close();
}
}