Java

Calculate The Pyramid Program Using Java

Calculate The Pyramid Program Using Java
import java.io.*; 
import java.lang.Math; 

class ssva19 
{ 
public static void main(String arg[]) throws IOException 
{ 
int i,j,k,m,n; 
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in)); 
System.out.println("\n PYRAMID "); 
System.out.println(" -------"); 
System.out.print("\nENTER THE PYRAMID RANGE : "); 
n=Integer.parseInt(obj.readLine()); 
System.out.println("\n"); 
m=n; 
for(i=1;i<=n;i++) 
{ 
m--; 
for(j=m;j>=1;j--) 
System.out.print(" "); 
for(j=1,k=i%10;j<=i;j++,k++) 
System.out.print(Math.abs(k%10)); 
for(j=2,k=k-2;j<=i;j++,k--) 
System.out.print(Math.abs(k%10)); 
System.out.println("\n"); 
} 
} 

}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.