-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiamond_shape.java
More file actions
46 lines (38 loc) · 1.18 KB
/
Diamond_shape.java
File metadata and controls
46 lines (38 loc) · 1.18 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
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package myprojects.assignment_1;
/**
*
* @author IHSANULLAH PC
*/
import java.util.Scanner;
public class Diamond_shape {
public static void main(String[] args)
{
int number;
System.out.println("please enter the number of rows :");
Scanner sca = new Scanner(System.in);
number=sca.nextInt();
int m, n;
for (m = 1; m <= number; m++) {
for (n = 1; n <= number - m; n++) {
System.out.print(" ");
}
for (n = 1; n <= m * 2 - 1; n++) {
System.out.print("*");
}
System.out.println();
}
for (m = number - 1; m > 0; m--) {
for (n = 1; n <= number - m; n++) {
System.out.print(" ");
}
for (n = 1; n <= m * 2 - 1; n++) {
System.out.print("*");
}
System.out.println();
}
}
}