Write a Java program to print right triangle of mirrored numbers pattern using for loop.
package Shapes3;
import java.util.Scanner;
public class RightTriMirroredColNum1 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
System.out.print("Enter Right Traingle Mirrored Numbers Rows = ");
int rows = sc.nextInt();
System.out.println("Right Traingle of Mirrored Numbers");
for (int i = 1; i <= rows; i++ )
{
for (int j = 1; j <= i; j++ )
{
System.out.print(j + " ");
}
for(int k = i - 1; k >= 1; k--)
{
System.out.print(k + " ");
}
System.out.println();
}
}
}

This example prints the right angled triangle pattern of mirrored numbers using while loop.
package Shapes3;
import java.util.Scanner;
public class RightTriMirroredColNum2 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
System.out.print("Enter Right Traingle Mirrored Numbers Rows = ");
int rows = sc.nextInt();
System.out.println("Right Traingle of Mirrored Numbers");
int i = 1;
while( i <= rows)
{
int j = 1;
while( j <= i )
{
System.out.print(j + " ");
j++;
}
int k = i - 1;
while( k >= 1)
{
System.out.print(k + " ");
k--;
}
System.out.println();
i++;
}
}
}
Enter Right Traingle Mirrored Numbers Rows = 9
Right Traingle of Mirrored Numbers
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
This Java program displays the right angled triangle pattern of numbers using the do while loop.
package Shapes3;
import java.util.Scanner;
public class RightTriMirroredColNum3 {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
System.out.print("Enter Right Traingle Mirrored Numbers Rows = ");
int rows = sc.nextInt();
System.out.println("Right Traingle of Mirrored Numbers");
rtMirroredColumnNumbers(rows);
}
public static void rtMirroredColumnNumbers(int rows)
{
for (int i = 1; i <= rows; i++ )
{
for (int j = 1; j <= i; j++ )
{
System.out.print(j + " ");
}
for(int k = i - 1; k >= 1; k--)
{
System.out.print(k + " ");
}
System.out.println();
}
}
}
Enter Right Traingle Mirrored Numbers Rows = 13
Right Traingle of Mirrored Numbers
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 12 11 10 9 8 7 6 5 4 3 2 1