-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnestedloops.java
More file actions
34 lines (24 loc) · 864 Bytes
/
Copy pathnestedloops.java
File metadata and controls
34 lines (24 loc) · 864 Bytes
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 nestedloops {
public static void main(String[] args){
// nested loop = A loop inside another loop
// Used often with matrices or DS&A
Scanner scanner = new Scanner(System.in);
int rows;
int columns;
char symbol;
System.out.print("Enter the # of rows: ");
rows = scanner.nextInt();
System.out.print("Enter the # of columns: ");
columns = scanner.nextInt();
System.out.print("Enter the symbol to use: ");
symbol = scanner.next().charAt(0);
for(int i = 0; i < rows; i++){
for(int j = 0; j < columns; j++){
System.out.print(symbol);
}
System.out.println();
}
scanner.close();
}
}