V W X Y and Z character pattern programs in Java

 

A to Z character pattern programs in java part 6

V W X Y and Z character pattern programs in Java

In this series of tutorial, we will study how to print character pattern programs in java. In this post, we will see how to create pattern V, W, X, Y and Z in Java.

 

1.  Character Pattern V in Java

In this tutorial we will study how to implement and print character pattern V in Java programming language.

import java.util.*;
class V
{
  public static void main(String[] args)
  {
    Scanner scan =new Scanner(System.in);
    System.out.println("enter the value of n");
    int n=scan.nextInt();
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(j>=0&&i==j&&i<=n/2||j>=0&&i+j==n-1&&i<=n/2)
        {
          System.out.print("*");
        }
        else
        {
          System.out.print(" ");
        }
      }
      System.out.println();
      
    }
  }
}

Output of pattern V in java

Enter the value of n
8
* *
* *
* *
**
**

2.  Character Pattern X in Java

In this tutorial we will study how to implement and display character pattern X in Java programming language.

import java.util.*;
class X
{
  public static void main(String[] args)
  {
    Scanner scan =new Scanner(System.in);
    System.out.println("enter the value of n");
    int n=scan.nextInt();
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(j>=0&&i==j||j>=0&&i+j==n-1)
        {
          System.out.print("*");
        }
        else
        {
          System.out.print(" ");
        }
      }
      System.out.println();
    }
  }
}

Output of pattern X in java

Enter the value of n
8
* *
* *
* *
**
**
* *
* *
* *

3.  Character Pattern Z in Java

In this tutorial we will study how to demonstrate and print character pattern Z in Java programming language.

import java.util.*;
class Z
{
  public static void main(String[] args)
  {
    Scanner scan =new Scanner(System.in);
    System.out.println("enter the value of n");
    int n=scan.nextInt();
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(j>=0&&i==0||j>=0&&i==n-1||i+j==n-1)
        {
          System.out.print("*");
        }
        else
        {
          System.out.print(" ");
        }
      }
      System.out.println();
    }
  }
}

Output of pattern Z in java

Enter the value of n
8
********
*
*
*
*
*
*
********

In these series of tutorials we will implement and demonstrate how to display character pattern programs in java, different diamond pattern programs in java. Also, printing number pattern programs in java, printing alphabet pattern programs in java, pattern programs in java with explanation, displaying string pattern programs in java, diamond number pattern programs in java, square pattern programs in java. These are the commonly asked pattern programs in many campus and off campus placement interviews.

If you find anything incorrect please contact us at click here. For regular updates please like the facebook page

Leave a Comment

Your email address will not be published. Required fields are marked *

Welcome to VTUPulse.com


Computer Graphics and Image Processing Mini Projects -> Click Here

Download Final Year Project -> Click Here

This will close in 12 seconds