In this tutorial, we will discuss Java code to triangle alphabet pattern using while loop
In this post, we will learn how to displayed Floyd’s triangle alphabet pattern using while loop or nested while loop in Java programming language
here, we displayed some alphabet Floyd’s triangle program with coding using nested while loop and also we get input from user using Scanner class in Java language
the user can provide numbers as they wish and get the alphabet pattern according to their input
Program 1
import java.util.Scanner;//import the scanner class class patternWhile1{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=1; while(j<=i){ System.out.print((char)(i+64)); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A BB CCC DDDD EEEEE FFFFFF
Program 2
import java.util.Scanner;//import the scanner class class PatternWhile2{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=1; while(j<=i){ System.out.print((char)(j+64)); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A AB ABC ABCD ABCDE ABCDEF
Program 3
import java.util.Scanner;//import the scanner class class PatternWhile3{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=i; while(j<=rows){ System.out.print((char)(i+64)); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 AAAAAA BBBBB CCCC DDD EE F
Program 4
import java.util.Scanner;//import the scanner class class PatternWhile4{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=i; while(j<=rows){ System.out.print((char)(j+64)); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 ABCDEF BCDEF CDEF DEF EF F
Program 5
import java.util.Scanner;//import the scanner class class PatternWhile5{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=rows; while(i>=1){ j=i; while(j<=rows){ System.out.print((char)(j+64)); j++; } i--; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 F EF DEF CDEF BCDEF ABCDEF
Program 6
import java.util.Scanner;//import the scanner class class PatternWhile6{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=i; while(j>=1){ System.out.print((char)(j+64)); j--; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A BA CBA DCBA EDCBA FEDCBA
Program 7
import java.util.Scanner;//import the scanner class class PatternWhile7{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=rows; while(i>=1){ j=rows; while(j>=i){ System.out.print((char)(j+64)); j--; } i--; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 F FE FED FEDC FEDCB FEDCBA
Program 8
import java.util.Scanner;//import the scanner class class PatternWhile8{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=1; while(j<=i){ System.out.print((char)(rows-i+1+64)); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 F EE DDD CCCC BBBBB AAAAAA
Program 9
import java.util.Scanner;//import the scanner class class PatternWhile9{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=rows; while(i>=1){ j=1; while(j<=i){ System.out.print((char)(i+64)); j++; } i--; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 FFFFFF EEEEE DDDD CCC BB A
Program 10
import java.util.Scanner;//import the scanner class class PatternWhile10{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=rows; while(j>=i){ System.out.print((char)(j+64)); j--; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 FEDCBA FEDCB FEDC FED FE F
Program 11
import java.util.Scanner;//import the scanner class class PatternWhile11{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=rows; while(i>=1){ j=i; while(j>=1){ System.out.print((char)(j+64)); j--; } i--; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 FEDCBA EDCBA DCBA CBA BA A
Program 12
import java.util.Scanner;//import the scanner class class PatternWhile12{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=i; while(j<=rows){ System.out.print((char)(j+64)+(" ")); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A B C D E F B C D E F C D E F D E F E F F
Program 13
import java.util.Scanner;//import the scanner class class PatternWhile13{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=1; while(i<=rows){ j=i; while(j>=1){ System.out.print((char)(j+64)+(" ")); j--; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A B A C B A D C B A E D C B A F E C D B A
Program 14
import java.util.Scanner;//import the scanner class class PatternWhile14{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j; i=rows; while(i>=1){ j=i; while(j>=1){ System.out.print((char)(j+64)+(" ")); j--; } i--; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 F E D C B A E D C B A D C B A C B A B A A
Program 15
import java.util.Scanner;//import the scanner class class PatternWhile15{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j,num,count; i=1; while(i<=rows){ num=rows-1; count=i; j=1; while(j<=i){ System.out.print((char)(count+64)+(" ")); count=count+num; num--; j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A B G C H L D I M P E J N Q S F K O R T U
Program 16
import java.util.Scanner;//import the scanner class class PatternWhile16{ public static void main(String args[]){ Scanner scan=new Scanner(System.in);//create a scanner object System.out.println("Enter the number of rows"); int rows=scan.nextInt(); int i,j,num,count; i=1; while(i<=rows){ j=1; while(j<=(i*2-1)){ System.out.print((char)(j+64)+(" ")); j++; } i++; System.out.println(); } } }
When the above code executed, it produces the following results
Enter the number of rows 6 A A B C A B C D E A B C D E F G A B C D E F G H I A B C D E F G H I J K
Suggested for you
Operator in Java
While loop in Java
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…