Alphabet triangle pattern using do-while loop in Java
- Home
- Alphabet Pattern
- Alphabet triangle pattern using do-while loop in Java
- On
- By
- 0 Comment
- Categories: Alphabet Pattern, Floyd's triangle
Alphabet triangle pattern using do-while loop in Java
Alphabet triangle pattern using the do-while loop in Java
In this article, we will discuss the concept of Alphabet triangle pattern using the do-while loop in Java programming language.
We can print various type of number, asterisk, binary patterns using for, while and do-while loop in Java language
In this post, we will discuss how to write a program to print different alphabet triangle pattern using the do-while loop in Java language.
To understand this example programs, you should have previous knowledge of following Java topics
Do while loop in Java language
Nested do while loop in Java language
Alphabet pattern using the do-while loop in Java
Program to Alphabet pattern 1
Program 1
import java.util.Scanner; class AlphabetPatternDoWhile1{ public static void main (String args[]){ int i,j; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows"); //get input from the user to number of rows int rows=scan.nextInt(); i=1; do{//outer loop j=1; do{//inner loop System.out.print((char)(i+64)); j++; }while( j<=i);//End of inner loop System.out.println(); i++; }while( i<=rows);//End of outer loop } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 2
Program 2
import java.util.Scanner; class AlphabetPatterndowhile2{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows"); //Takes input from the user to number of rows int rows=scan.nextInt(); i=1; do{ j=1; do{ System.out.print((char)(j+letter)); j++; }while( j<=i); System.out.println(); i++; }while(i<=rows); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 3
Program 3
import java.util.Scanner; class AlphabetPatterndowhile3{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; do{ j=rows; do{ System.out.print((char)(j+letter)); j--; }while( j>=i); System.out.println(); i--; }while(i>=1); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 4
Program 4
import java.util.Scanner; class AlphabetPatterndowhile4{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; while(i>=1){ j=1; while(j<=i){ System.out.print((char)(j+letter)); j++; } System.out.println(); i--; } } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 5
Program 5
import java.util.Scanner; class AlphabetPatterndowhile5{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ j=rows; do{ System.out.print((char)(i+letter)); j--; } while(j>=i); System.out.println(); i++; }while(i<=rows); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 6
Program 6
import java.util.Scanner; class AlphabetPatterndowhile6{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; do{ j=i; do{ System.out.print((char)(j+letter)); j++; } while(j<=rows); System.out.println(); i--; }while(i>=1); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 7
Program 7
import java.util.Scanner; class AlphabetPatterndowhile7{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ j=i; do{ System.out.print((char)(j+letter)); j--; }while( j>=1); System.out.println(); i++; }while(i<=rows) } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 8
Program 8
import java.util.Scanner; class AlphabetPatterndowhile8{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ j=1; do{ System.out.print((char)(rows-i+1+letter)); j++; } while( j<=i); System.out.println(); i++; }while(i<=rows); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 9
Program 9
import java.util.Scanner; class AlphabetPatterndowhile9{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; do{ j=1; do{ System.out.print((char)(i+letter)); j++; } while( j<=i); System.out.println(); i--; }while(i>=1); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 10
Program 10
import java.util.Scanner; class AlphabetPatterndowhile10{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user to number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; do{ j=i; do{ System.out.print((char)(j+letter)); j--; }while(j>=1); System.out.println(); i--; }while( i>=1); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 11
Program 11
import java.util.Scanner; class AlphabetPatterndowhile11{ public static void main (String args[]){ int i,j,k=1; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user for number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ j=1; do{ System.out.print((char)(k+letter)); j++; k++; }while( j<=i); System.out.println(); i++; }while( i<=rows); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 12
Program 12
import java.util.Scanner; class AlphabetPatterndowhile12{ public static void main (String args[]){ int i,j,k=1; int letter=64; int num,count; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user for number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ num=rows-1; count=i; j=1; do{ System.out.print((char)(count+letter)); count=count+num; num--; j++; }while( j<=i); System.out.println(); i++; }while(i<=rows); } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 13
Program 13
import java.util.Scanner; class AlphabetPatternDowhile{ public static void main (String args[]){ int i,j,k; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user for number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=rows; while( i>=1){ k=i; j=1; while(j<=i){ System.out.print((char)(k+letter)); j++; k++; } System.out.println(); i--; } } }
When the above code is executed, it produces the following results
Program to Alphabet pattern 14
Program 14
import java.util.Scanner; class AlphabetPatterndowhilefif{ public static void main (String args[]){ int i,j; int letter=64; Scanner scan=new Scanner(System.in); System.out.print("Enter the number of rows: "); //get input from the user for number of rows int rows=scan.nextInt(); System.out.print("\nYour pattern here\n\n"); i=1; do{ j=i; do{ System.out.print((char)(j+letter)); j++; } while( j<=rows); System.out.println(); i++; }while( i<=rows); } }
When the above code is executed, it produces the following results
Suggested for you
Data type and variable in Java language
Similar post
C code to Alphabet triangle pattern using the do-while loop
C++ code to Alphabet triangle pattern using the do-while loop
Java code to Alphabet triangle pattern using the do-while loop
Alphabet pattern in C language
Alphabet triangle pattern in C language using while loop
Alphabet pattern in Java language
Alphabet triangle pattern in Java language using while loop
Alphabet pattern in C++ language
Alphabet triangle pattern in C++ language using while loop