-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashOutput.java
More file actions
36 lines (29 loc) · 1.91 KB
/
Copy pathDashOutput.java
File metadata and controls
36 lines (29 loc) · 1.91 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
public class DashOutput {
public static void main(String[] args) {
// This program outputs a bunch of dashes using arrays
/* Expected Output:
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
*/
printDash();
}
private static void printDash() {
// Create a 2D array called "dash" containing the character '-'.
char[][] dash = new char[10][10];
for (int i = 0; i < dash.length; i++) { // Lopp through each row of the 2D array
for (int j = 0; j < dash[i].length; j++) { // Loop through each element of the 2D array
dash[i][j] = '-'; // Assign dash character to element in array
System.out.print(dash[i][j] + " "); // Print dash followed by a space
}
System.out.println(); // Move to the next line after printing each row
}
}
}