/**Program For Design pattern in java**/
import java.io.*;
class loop
{
int i,j,n;
public void getdata()throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF LINES TO BE PRINTED:");
n=Integer.parseInt(br.readLine());
}
public void display()
{
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
public static void main(String args[])throws Exception
{
loop l=new loop();
l.getdata();
l.display();
}
}
import java.io.*;
class loop
{
int i,j,n;
public void getdata()throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER THE NUMBER OF LINES TO BE PRINTED:");
n=Integer.parseInt(br.readLine());
}
public void display()
{
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
System.out.print("*");
}
System.out.println(" ");
}
}
public static void main(String args[])throws Exception
{
loop l=new loop();
l.getdata();
l.display();
}
}
No comments:
Post a Comment