JAVA
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
import java.io.*;
public class Diamond
{
public static void main(String args[]) throws IOException
{
InputStreamReader read= new InputStreamReader(System.in);
BufferedReader in= new BufferedReader(read);
int a,b,i,j,k=1,l;
System.out.println("Enter the number of layers");
System.out.println("Please do not enter an even value, if you do, it will be raised by 1.");
try
{
a=Integer.parseInt(in.readLine());
}
catch(Exception e)
{
System.out.println("The diamond is being drawn with default value");
a=9;
}
if(a%2==0)
{
a++;
}
b=a/2;
a-=b;
for(i=a;i>=1;i--)
{
for(j=1;j<=i;j++)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run