-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStairCase_05.java
42 lines (32 loc) · 982 Bytes
/
StairCase_05.java
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
35
36
37
38
39
40
41
42
package MountBlue_01;
import java.util.Scanner;
public class StairCase_05 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int n = input.nextInt();
staircase(n);
}
static void staircase(int n) {
// We run two for loop outer loop for row and inner loop for column
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
// add value of i and j if it's greater than n then we simply print # else print empty value
if((i + j) > n ){
System.out.print("#");
}
else{
System.out.print(" ");
}
}
// after the inner loop we have go the next line so this following method for new line
System.out.println();
}
}
}
/*
This is a staircase of size N = 4:
#
##
###
####
*/