Number pattern

Program to display integrated pyramid number pattern in Java using while loop

Java program to display integrated pyramid number pattern using while loop

In this tutorial, we will discuss a concept of  Java program to display integrated pyramid number pattern using while loop

In the Java programming  language, we can use for loop ,while loop and do-while loop to display different number (binary, decimal), alphabets or star pattern programs.

In this article, we are going to learn  how to Display integrated pyramid number pattern using while loop  in Java language

Java code to Integrated triangle number patterns

Integrated Triangle number pattern 1

Program 1

 

import java.util.Scanner;
class DoublePyramidWhile{
public static void main(String args[]){
    int i,j;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

System.out.print("Enter the number of rows: ");
int row=scan.nextInt();  //get input from user
i=1;
while(i<=row){//print upper part of shape
    j=i;
    while(j<=row){
        System.out.print(j);
        j++;
    }
    i++;
    System.out.print("\n");
}

i=row-1;
while(i>=1){
    j=i;
    while(j<=row){
        System.out.print(j);
        j++;
    }
    i--;
    System.out.print("\n");
}
}
}

 

When the above code is executed, it produces the following results

integrated pyramid number pattern 1

 

Integrated Triangle number pattern 2

Program 2

import java.util.Scanner;
class DoublePyramidWhile1{
public static void main(String args[]){
    int i,j;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

System.out.print("Enter the number of rows: ");
int row=scan.nextInt();//get input from user
i=1;
while(i<=row){//print upper part of shape
    j=1;
while(j<i){
    System.out.print(" ");//print space
    j++;
}
j=i;
    while(j<=row){
        System.out.print(j);
        j++;
    }
    i++;
    System.out.print("\n");
}

i=row-1;
while(i>=1){//print lower part of shape
    j=1;
while(j<i){
    System.out.print(" ");
    j++;
}
j=i;
    while(j<=row){
        System.out.print(j);
        j++;
    }
    i--;
    System.out.print("\n");
}

}
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 2

Integrated Triangle number pattern 3

Program 3

import java.util.Scanner;
class DoublePyramidWhile7{
public static void main(String args[]){
    int i,j,k;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

//get input from the user for rows
System.out.print("Enter the number of rows: ");
int rows=scan.nextInt();//get input from user
i=rows;
while(i>=1){
j=1; 
     while(j<=i){
         System.out.print(j);
        
          j++;
             }
              System.out.print("\n");
             i--;
}
i=1;
     while( i<rows){//print lower part of shape
         j=1;
         while(j<=i){
         System.out.print(j);
         
          j++;
             }
             System.out.print("\n");
         
          i++;
         }
        
    }
}

When the above code is executed, it produces the following results

integrated pyramid number pattern 3

Integrated Triangle number pattern 4

program 4

import java.util.Scanner;
class DoublePyramidWhile2{
public static void main(String args[]){
    int i,j;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

System.out.print("Enter the number of rows: ");
int row=scan.nextInt();   //get input from user
i=1;
while(i<=row){//print upper part of shape
    j=1;
while(j<=i){
    System.out.print(" ");//print space
    j++;
}
j=i;
    while(j<=row){
        System.out.print(j+" ");//print number with space
        j++;
    }
    i++;
    System.out.print("\n");
}

i=row-1;
while(i>=1){//print lower part of shape
    j=1;
while(j<=i){
    System.out.print(" ");
    j++;
}
j=i;
    while(j<=row){
        System.out.print(j+" ");
        j++;
    }
    i--;
    System.out.print("\n");
}

}
}

When the above code is executed, it produces the following results

integrated pyramid number pattern 4

Integrated Triangle number pattern 5

Program 5

import java.util.Scanner;
class DoublePyramidWhile3{
public static void main(String args[]){
    int i,j,k;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

System.out.print("Enter the number of rows: ");
int row=scan.nextInt();//get input from user
i=1;
while(i<=row){//print upper part of shape
    j=1;
while(j<=row-i){
    System.out.print(" ");//print space
    j++;
}
j=1;
    while(j<=i){
        System.out.print(j+" ");//print number with space
        j++;
    }
    i++;
    System.out.print("\n");
}

i=1;
while(i<=row-1){//print lower part of shape
    j=1;
while(j<=i){
    System.out.print(" ");
    j++;
}
j=1;
    while(j<=row-i){
        System.out.print(j+" ");
        j++;
    }
    i++;
    System.out.print("\n");
}

}
}

When the above code is executed, it produces the following results

Integrated pyramid number pattern 5

Integrated Triangle number pattern 6

Program 6

import java.util.Scanner;
class DoublePyramidWhile4{
public static void main(String args[]){
    int i,j,k;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

//get input from the user for rows
System.out.print("Enter the number of rows: ");
int rows=scan.nextInt();//get input from user

i=1; 
while(i<=rows){
  for(j=1; j<=i; j++){
  System.out.print(j);
  
}

j=i*2; 
while(j<rows*2){
  System.out.print(" ");
   j++;
}

k=i;
while( k>=1){
  System.out.print(k);
   k--;
}

  System.out.print("\n");
  
   i++;

}
}
}

When the above code is executed, it produces the following results

integrated pyramid number pattern 6

 

Integrated Triangle number pattern 7

Program 7

import java.util.Scanner;
class DoublePyramidWhile5{
public static void main(String args[]){
    int i,j,k;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

//get input from the user for rows
System.out.print("Enter the number of rows: ");
int rows=scan.nextInt();//get input from user

i=rows; 
while(i>=1){  //parent while loop
    j=rows; 
  while(j>=1+rows-i){
  System.out.print(j);
  
   j--;
  
}
     j=i*2; 
    while(j<rows*2-1){
  System.out.print(" ");
  j++;
  
    }

    k=1+rows-i;
    while( k<=rows){
    if(k!=1)
  System.out.print(k);
 k++;
  
   }

  System.out.print("\n");
  i--;

}
}
}

When the above code is executed, it produces the following results

integrated pyramid number pattern 7

 

Integrated Triangle number pattern 8

Program 8

import java.util.Scanner;
class DoublePyramidWhile6{
public static void main(String args[]){
    int i,j,k;  //variable declaration
    Scanner scan=new Scanner(System.in);
//create a scanner object for input

//get input from the user for rows
System.out.print("Enter the number of rows: ");
int rows=scan.nextInt();//get input from user
i=rows;
while(i>=1){
j=1; 
     while(j<=i){
         System.out.print(j);
          j++;
             }
j=i*2;
     while( j<rows*2-1){
         System.out.print(" ");
          j++;
            }
k=i;;
     while( k>=1){
        if(k!=rows)
         System.out.print(k);
          k--;
              }
System.out.print("\n");
 i--;
         }
    }
}

When the above code is executed, it produces the following results

integrated pyramid number pattern 8

Similar post

C program to display integrated pyramid number pattern using while loop

Java program to display integrated pyramid number pattern using while loop

C++ program to display integrated pyramid number pattern using while loop

C++ code to Integrated triangle patterns using for loop

Java code to Integrated triangle patterns using for loop

Pascal Triangle pattern in Java Language using Array

C Language Pascal Triangle pattern in  using 2D Array

Java Language Pascal Triangle pattern in  using 2D Array

Java program to star Pyramid pattern

C# program to inverted star Pyramid pattern

Python program to star Pyramid pattern

 

 

 

Suggested for you

Data types and variable in Java language

While loop in  Java  language

Nested while loop in Java language

Operator in Java language

 

 

C++ Program to display integrated pyramid number pattern using while loop
C program to print combined Pyramid pattern
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago