Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HollowDiamond {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Please enter a number : ");
- int n = input.nextInt();
- for (int row = 1; row <=n; row++) {
- for (int col = 1; col <=n-row; col++) {
- System.out.print(" ");
- }
- for (int col = 1; col <=row; col++) {
- if(col==row){
- System.out.print("*");
- }
- else{
- System.out.print(" ");
- }
- }
- for (int col = 2; col <=row; col++) {
- if(row==col){
- System.out.print("*");
- }
- else{
- System.out.print(" ");
- }
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement