×

India Map Pattern in Java

India Map Pattern is the pattern we'll code now using Java, as demonstrated.

We will use a star in Java to print our India map.The specialty is that we will only utilize it for printing the India Map Pattern in loops.

Program for the India Map Pattern in Java

import java.io.*;
importjava.util.*;
public class IndiaMap
{
 public static void main(String[] args)
 {
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=14; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=4*i+2; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<(12+i+i)+2; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=(2*8-i); j++)
    {
System.out.print("*");
    }
System.out.println ();
  } 
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=14+i; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=3*(4-i+2); j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=(12+i+i)+2; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=18; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*i+6; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(9-i+1)-1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*i+12; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(7-i+1); j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=3*i+13; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=3*(11-i+1)+1; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=5*i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<2*(10-5*(i)+(i*2)-1)+i-1; j++)
    {
System.out.print (" ");
    }
for(int k=1; k<=7*i+16; k++)
    {
System.out.print("*");
    }
for(int j=1; j<=2*(8-i+1); j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=i; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=4*(2-i+1)+1; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=2*i+8; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }  
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=i+4; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=24*i+13; j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("        **      ********");
    }
System.out.println();
  }
for(int i=1; i<=2; i++)
  {
for(int j=1; j<=i+6; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=2*(22-i+2); j++)
    {
System.out.print("*");
    }
for(int j=1; j<=i; j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=1-i+1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=4+2*i; j++)
    {
System.out.print("*");
    }
for(int j=1; j<=1-i+1; j++)
    {
System.out.print(" ");
    }
    for (int j=1; j<=(40+i+i)+2; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=2*(4-i+1); j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=7-i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=2*(2-i+1); j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=4*i+45; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=8; j++)
    {
System.out.print(" ");
    }
    for (int j=1; j<=2*(2-i+1)-1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=3+i; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=7-i; j++)
    {
System.out.print("*");
    }
    for (int j=1; j<=1; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=40-2*i+1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12-i+1; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=35; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=30; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=12; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=2*(14-i+1); j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("  ");
    }
System.out.println ();
  } 
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=i+11;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=25-i+1; j++)
    {
System.out.print("*");
    }
for(int j=i; j<=1; j++)
    {
System.out.print("  ");
    }

System.out.println();
  }
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=14;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=20-i+1; j++)
    {
System.out.print("*");
    }
System.out.println();
  }
for(int i=1;i<=2;i++)
  {
for(int j=1;j<=i+14;j++)
    {
System.out.print(" ");
    }
for(int j=1; j<=16; j++)
    {
System.out.print("*");
    }
System.out.println();
  }  
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=i+15; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=15-i+1; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 3; i++)
  {
    for (int j=1; j<=18; j++)
    {
System.out.print (" ");
    }
for(int j=1; j<=12; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 2; i++)
  {
    for (int j=1; j<=20; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=10-2*i; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
  for (int i = 1; i<= 1; i++)
  {
    for (int j=1; j<=21; j++)
    {
System.out.print (" ");
    }
    for (int j=1; j<=4; j++)
    {
System.out.print("*");
    }
System.out.println ();
  }
 }
}

The output of the above program

India Map Pattern in Java

Related Topics

Sudoku in Java

Sudoku is a combinatorial-number-placement puzzle with a logic-based approach. The goal of a traditional Sudoku puzzle is to fill in the numbers on a 9 by 9 grid so that...

6 minutes read.

Java Short Keyword

Java supports eight different primitive datatypes. The language has predefined primitive datatypes that are given keyword names. Let's take a closer look at each of the eight primitive data types....

3 minutes read.

Difference between this and super in Java

In this article, you will be very well equipped with the knowledge of this keyword and super keyword in java. You will be able to understand where to implement this...

3 minutes read.

Java String Reader

StreamReaderClass: This class is present in the java.io package. It is a character stream in which string act as a source.This method provides to read characters from a string. Character Stream: This class...

3 minutes read.

Dangling Else problem in Java

A language interpretation uncertainty is the hanging other issue. The following two types of condition executed code are both possible in programming: 1. if-then-else form 2. if-then form When dealing with the nested...

3 minutes read.

Java Lambda foreach

Before understanding lamda foreach, one must know about foreach loop in Java. foreach loop in Java Since J2SE 5.0, there has been a for-each loop in Java, also known as an extended...

4 minutes read.

Java String length() method

Java String length() method returns length of the characters in a String. Syntax: public int length() Returns It returns length of the characters Java String length() method example 1          public class JavaStringLengthEx1  ...

1 minute read.

Chromatic Number in Java

The chromatic number is the bare minimum of colours necessary to accurately colour any graph. To put it another way, the chromatic number can be thought of as the bare...

6 minutes read.

Moran Numbers in Java

In this article, we will be acknowledged about the moran numbers in Java, how they are formed, what are the approaches to achieve the moran numbers. Moran Number A moran numbers are...

3 minutes read.

Java class class

Java Class class instances are an executing Java application's implementation of the classes and interfaces. As well as, every Array is indeed an object that is common for all Arrays...

6 minutes read.

Abstract Class Program in Java

Abstract Class Program in Java Abstraction is a technique by which a developer hides the implementation details from the user and shows only the functionality.It is not only confined to the...

6 minutes read.

How Many Ways to Create Objects in Java

Introduction Java comes under the category of object-oriented programming languages. Since it is object-oriented, everything in Java is considered an object. Java is a diverse programming language that is designed to...

6 minutes read.

Method and Block Synchronization in Java

The Synchronization is performed in multi-threading concept. The multi-threading is a concept of parallel running of a program for the execution. In the multi-threading concept, the threads are run by...

3 minutes read.

How to initialize string array in Java

In this tutorial, we will learn how the string array is initialized in java. The initialization of string array in the java by using the NEW (it creates the object for...

3 minutes read.

Java String intern() method

Java String intern() method returns canonical representation for the String Object. syntax: public String intern() Return: It returns a interned String that to be a pool of unique String. Java String intern() Example 1 public class...

2 minutes read.

Java String concat() method:

Java String concat() method is used to add the given String to the end of the current String. Syntax: public String concat(String str) Parameter: Str: String to be concatenated at the end of current...

1 minute read.

Different Ways to Take Input from User in Java

Any information provided to a system for use is known as user input. Any responsive software or application must include user input. In Java, there are 4 different ways to...

5 minutes read.

Java Instanceof Keyword

To determine whether an object is an instance of the supplied type in Java, use the instanceof operator (class or subclass or interface). The type of comparison in java differentiates the...

4 minutes read.

How to Convert String to long in Java

How to Convert String to long in java It is used when you want to perform the mathematical operation on the String which contains long number then the conversion from String...

4 minutes read.

How to check data type in Java

In this section, we will learn about the methodology to verify the data type in Java. There are mainly two methods in java called as getClass() and getName(). They are...

3 minutes read.