-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiamondWithName.java
More file actions
34 lines (31 loc) · 1.09 KB
/
DiamondWithName.java
File metadata and controls
34 lines (31 loc) · 1.09 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
package com.company;
import java.util.Scanner;
/**
* Created by Saikumar-Kabaaliraaa on 01-Jul-17.
*/
public class DiamondWithName {
public static void main(String a[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter n value: ");
new DiamondWithName().printDiamondWithNameAndStars(input.nextInt());
}
public void printDiamondWithNameAndStars(int no_of_stars){
for(int i=1;i<=no_of_stars-1;i++){
for(int j=1;j<=no_of_stars*2-1;j++) {
if (j < no_of_stars - i + 1 || j > no_of_stars + i - 1)
System.out.print(" ");
else System.out.print("*");
}
System.out.println();
}
System.out.println("Saikumar");
for(int i=no_of_stars-1;i>=1;i--){
for(int j=1;j<=no_of_stars*2-1;j++) {
if (j < no_of_stars - i + 1 || j > no_of_stars + i - 1)
System.out.print(" ");
else System.out.print("*");
}
System.out.println();
}
}
}