Computer Science, asked by dipeshp923, 9 months ago

Write a java program to print the following pattern.
Here underscore means space.
Do write a proper program which is related to bluej environment

Attachments:

Answers

Answered by charlie1505
0

Answer:

import java.util.Scanner;

public class Num_Pattern

{

public static void main(String[] args)

{

// Create a new Scanner object

Scanner scanner = new Scanner(System.in);

// Get the number of rows from the user

System.out.println("Enter the number of rows to print the pattern ");

int rows = scanner.nextInt();

System.out.println("** Printing the pattern... **");

for (int i = 1; i <= rows; i++)

{

for (int j = 1; j <= i; j++)

{

System.out.print(j);

}

for (int j= i*2 ; j < rows*2; j++)

{

System.out.print(" ");

}

for (int l = i; l >= 1; l--)

{

System.out.print(l);

}

System.out.println();

}

scanner.close();

}

}

Similar questions