Write a Java program to print following pattern:
* *
** **
*** ***
**** ****
**********
plz plz plz help me with this program please.... answer should be correct ... please please...
Answers
Answer :
import java.util.*;
public class answer
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
System.out.println("* *");
System.out.println("** **");
System.out.println("*** ***");
System.out.println("**** ****");
System.out.println("**********");
}
}
Hope this helps you.
Answer:
Pattern Programs in Java
Star Patterns in Java
Numeric Patterns
Character Patterns
Let’s get started. :-)
Star Patterns in Java
First, let us begin with the basic and the commonly asked pattern program in Java i.e Pyramid.
1. Pyramid Program
*
* *
* * *
* * * *
* * * * *
Let’s write the java code to understand this pattern better.
public class Edureka
{
public static void pyramidPattern(int n)
{
for (int i=0; i<n; i++) //outer loop for number of rows(n) { for (int j=n-i; j>1; j--) //inner loop for spaces
{
System.out.print(" "); //print space
}
for (int j=0; j<=i; j++ ) //inner loop for number of columns
{
System.out.print("* "); //print star
}