Program to print string in design using nested for loop in java programming.

Program to print string in following design using nested for loop in java programming:


import java.lang.*;
import java.io.*;
import java.util.*;
class Pattern extends Exception
{
public static void main(String[] str)
{
try
{
Scanner s=new Scanner(System.in);
String str1,str2;
int i;
System.out.println("                                        www.a3programming.blogspot.com");
System.out.println("Enter Name Sir:");
str1=s.next();
for(i=0; i<=str1.length(); i++)
{
str2=str1.substring(0,i);
System.out.println(str2);
}
}
catch(ArithmeticException e)
{
System.out.println(e);
}
finally
{
System.out.println("Good Bye");
}
}
}



Expected output is:


Post a Comment

0 Comments