Skip to content

Commit f5ce88f

Browse files
committed
Basic:- Solution to Star Pattern II Printing
1 parent 3ad3968 commit f5ce88f

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎src/Scaler/Assignments/PatternPrinting.java‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@ public class PatternPrinting {
66
public static void main(String[] args) {
77
Scanner scanner = new Scanner(System.in);
88
int number = scanner.nextInt();
9+
//------------------------------------------------------------------------
10+
// Star Pattern II
11+
/*
12+
*******
13+
* *
14+
* *
15+
* *
16+
* *
17+
**
18+
*
19+
*/
20+
21+
for (int k=1; k <= number; k++) {
22+
System.out.print("*");
23+
}
24+
System.out.println();
25+
26+
int innerloop = number-1;
27+
28+
for (int i=1; i <= innerloop; i++) {
29+
System.out.print("*");
30+
31+
int spaces = innerloop-i-1;
32+
33+
for (int j = 1; j <= spaces; j++) {
34+
System.out.print(" ");
35+
}
36+
if(i != innerloop){System.out.println("*");}
37+
}
38+
39+
System.out.println();
40+
41+
//------------------------------------------------------------------------
942

1043
//------------------------------------------------------------------------
1144
/*

0 commit comments

Comments
 (0)