This is a simple Java Program which prints out a Palindrome triangle with respect to the given input.
|
Java Program to print Palindrome triangle |
PROGRAM :package codingcorner.in;
import java.util.Scanner;
public class PalindromeTriangle {
public static void main(String[] args) {
int i, j, n;
Scanner scan = new Scanner(System.in);
System.out.print("Enter number of lines[height of triangle] : \t");
n = scan.nextInt();
scan.close();
for (i = 1; i <= n; i++) {
for (j = i; j < n; j++)
System.out.print(" ");
for (j = 1; j <= i; j++)
System.out.print(j);
for (j = i - 1; j >= 1; j--)
System.out.print(j);
System.out.print("\n");
}
}
}
OUTPUT : |
Java Program to print Palindrome triangle |
Really Nice Post to Print Star Pattern in Java Yesterday I visit this blog and i was found lots of helpful information from your side thanks for sharing updated and New Technology related Post.
ReplyDeleteThis article regarding Print Star Pattern in Java is common for every java learner and thanks for sharing above codes in java programming.
ReplyDelete* *
* * * *
* * * * * * * *
* * * * * * * * * * * * * * * *
Please give code for above pattern Print Triangle of Stars in Java
public static void main(String[]args)
Delete{
int row=4;
int star=2;
int mul=0;
for(int rowC=1; rowC<=row; rowC++)
{
for(int starC=1; starC<=star; starC++)
{
System.out.print("*");
}
mul++;
star+=Math.pow(2,mul);
System.out.println();
}
}