-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaircase.java
More file actions
30 lines (27 loc) · 771 Bytes
/
staircase.java
File metadata and controls
30 lines (27 loc) · 771 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class staircase{
public static void main(String[] args) {
int height,width;
Scanner reader = new Scanner(System.in);
height = reader.nextInt();
//input validation
if(height > 0){
//set width equal to height
//print width first
for(int i=1;i<height;i++){
System.out.println('#');
//formatting
//increment width with i
width = i;
//print width coresponding to height
for (int j =0;j<width;j++){
System.out.print('#');
}
}
}
}
}