MCPcopy Create free account
hub / github.com/apna-college/Alpha / diamond

Method diamond

0_JavaProgrammingBasics/Patterns/Patterns.java:146–174  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

144 }
145
146 public static void diamond(int n) {
147 //1st half
148 for(int i=1; i<=n; i++) {
149 //spaces
150 for(int j=1; j<=n-i; j++) {
151 System.out.print(" ");
152 }
153
154 //stars
155 for(int j=1; j<=(2*i)-1; j++) {
156 System.out.print("*");
157 }
158 System.out.println();
159 }
160
161 //2nd half
162 for(int i=n; i>=0; i--) {
163 //spaces
164 for(int j=1; j<=n-i; j++) {
165 System.out.print(" ");
166 }
167
168 //stars
169 for(int j=1; j<=(2*i)-1; j++) {
170 System.out.print("*");
171 }
172 System.out.println();
173 }
174 }
175
176 public static void number_pyramid(int n) {
177 for(int i=1; i<=n; i++) {

Callers 1

mainMethod · 0.95

Calls 1

printMethod · 0.45

Tested by

no test coverage detected