Q:

Calculate The Pyramid Program Using Java

0

This Program is used to display the Pyramid Program.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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"); 
} 
} 

}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now