-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson10NestedLoop.java
More file actions
34 lines (29 loc) · 1.03 KB
/
Lesson10NestedLoop.java
File metadata and controls
34 lines (29 loc) · 1.03 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
33
34
import java.util.Scanner;
public class Lesson10NestedLoop {
public static void main(String[]args){
// nested loop= A loop inside another loop
// used often with matrices or DS&A(data structures and algorithms)
// for (int i = 1; i <=3 ; i++) {
// for (int j = 0; j < 9; j++) {
// System.out.print(j+" ");
//
// }
// System.out.println(i);
//
// }
// creating a matrix
Scanner scanner=new Scanner(System.in);
int rows,columns;
char symbol;
System.out.print("Enter the number of rows: ");
rows= scanner.nextInt();
System.out.print("Enter the number of columns: ");
columns= scanner.nextInt();
System.out.print("Enter the number of symbol: ");
symbol= scanner.next().charAt(0);
for (int j= 0; j<rows;j++){
for (int i = 0; i <columns;i++){
System.out.print(symbol);
}
System.out.println();}
}}