Question 3.07:Write a Java program by using three for loops to print the following pattern:
1******
12*****
123****
1234***
12345**
123456*
1234567
Solution:
package com.company;
import java.util.Scanner;
public class Lab3Problem7 {
public static void main(String[] args)
{
Scanner Obj = new Scanner(System.in);
System.out.print("Enter the size: ");
int n =Obj.nextInt();
for(int i=0;i<=n;i++)
{
for(int k=1;k<=i;k++)
{
System.out.print(k);
}
for(int j=0;j<=n-i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}