//Program for Up - Down Pattern
//Developed by Ahlam Ansari
import java.io.*;
import java.util.*;
class ptrn2
{
public static void main(String ahlam[])
{
int m;
System.out.println("Enter the number of rows");
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
for(int i=0;i<m;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
for(int i=1;i<m;i++)
{
for(int j=1;j<m-i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
/*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>javac ptrn2.java
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>java ptrn2
Enter the number of rows
5
*
**
***
****
***
**
*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>
*/
//Developed by Ahlam Ansari
import java.io.*;
import java.util.*;
class ptrn2
{
public static void main(String ahlam[])
{
int m;
System.out.println("Enter the number of rows");
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
for(int i=0;i<m;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
for(int i=1;i<m;i++)
{
for(int j=1;j<m-i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
/*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>javac ptrn2.java
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>java ptrn2
Enter the number of rows
5
*
**
***
****
***
**
*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>
*/
No comments:
Post a Comment