Wednesday, 30 December 2020

Pattern 1, 2, 3 and 4

public class p10 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print("* ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

* * * * * 
  * * * * 
    * * * 
      * * 
        * 
 
public class P30 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print("* ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

* * * * * 
* * * *   
* * *     
* *       
*         
public class P28 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print("* ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

*         
* *       
* * *     
* * * *   
* * * * * 
public class P29 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print("* ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

        * 
      * * 
    * * * 
  * * * * 
* * * * *

Pattern 25, 26, 27, 28, 29 and 30

public class P22 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=5; j>0;j--)
			{
				if(i>=j)
					System.out.print(j+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
5 4 3 2 1 
  4 3 2 1 
    3 2 1 
      2 1 
        1 

public class p11 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print(i+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
1 1 1 1 1 
  2 2 2 2 
    3 3 3 
      4 4 
        5 

public class p12 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print(j+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}	
}
OUTPUT
1 2 3 4 5 
  2 3 4 5 
    3 4 5 
      4 5 
        5 

public class p17 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print((char)(64+j)+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
A B C D E 
  B C D E 
    C D E 
      D E 
        E 
public class P21 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=5; j>0;j--)
			{
				if(i>=j)
					System.out.print(i+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
5 5 5 5 5 
  4 4 4 4 
    3 3 3 
      2 2 
        1 

public class p18 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print((char)(64+i)+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
A A A A A 
  B B B B 
    C C C 
      D D 
        E 

Pattern 14, 15, 16, 17, 18 and 19

public class p14
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print(j+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
1         
1 2       
1 2 3     
1 2 3 4   
1 2 3 4 5 
public class p15 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print(i+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
1         
2 2       
3 3 3     
4 4 4 4   
5 5 5 5 5 
public class p16 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print((char)(64+j)+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
A         
A B       
A B C     
A B C D   
A B C D E 
public class P17 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=5; j>0;j--)
			{
				if(i<=j)
					System.out.print(i+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
5         
4 4       
3 3 3     
2 2 2 2   
1 1 1 1 1 
public class P18 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=5; j>0;j--)
			{
				if(i<=j)
					System.out.print(j+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
5         
5 4       
5 4 3     
5 4 3 2   
5 4 3 2 1 
public class p16 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i>=j)
					System.out.print((char)(64+i)+" ");
				else
					System.out.print("  ");
			}
		System.out.println();
		}
	}
}
OUTPUT
A         
B B       
C C C     
D D D D   
E E E E E 

Thursday, 24 December 2020

Pattern 12 & 13

import java.util.*;
public class p8 {
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("Enter How many rows you want?");
		int n=s.nextInt();
		
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=n-i;j++)
			{
				System.out.print(" ");
			}	
			for(int j=1; j<=2*i-1;j++)
			{
				if(i%2==0 && (j==1||j==(i*2-1)))
					System.out.print("+");
				else
					System.out.print("*");
			}
		System.out.println();
		}
	}
}

OUTPUT
       *
      +*+
     *****
    +*****+
   *********
  +*********+
 *************
+*************+


import java.util.*;
public class p9 {
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("Enter How many rows you want?");
		int n=s.nextInt();
		
		for(int i=n; i>0; i--)
		{
			for(int j=1; j	<=n-i;j++)
			{
				System.out.print(" ");
			}	
			for(int j=1; j	<=2*i-1;j++)
			{
				if(i%2==0&&(j==1||j==(i*2-1)))
					System.out.print("+");
				else
					System.out.print("*");
			}
		System.out.println();
		}
	}
}

OUTPUT

*************
 +*********+
  *********
   +*****+
    *****
     +*+
      *

Sunday, 20 December 2020

Pattern 8, 9, 10 and 11

public class p3 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i==j)
					System.out.print("1 ");
				else
					System.out.print("0 ");
			}
		System.out.println();
		}
	}
}
OUTPUT

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 

public class p5 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i<=j)
					System.out.print("1 ");
				else
					System.out.print("0 ");
			}
		System.out.println();
		}
	}
}
OUTPUT

1 1 1 1 1 
0 1 1 1 1 
0 0 1 1 1 
0 0 0 1 1 
0 0 0 0 1 
public class p6 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(j<=i)
					System.out.print("1 ");
				else
					System.out.print("0 ");
			}
		System.out.println();
		}
	}
}

OUTPUT

1 0 0 0 0 
1 1 0 0 0 
1 1 1 0 0 
1 1 1 1 0 
1 1 1 1 1 
public class p7 {
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				if(i==j)
					System.out.print("* ");
				else if(i<j)
					System.out.print("1 ");
				else
					System.out.print("o ");
			}
		System.out.println();
		}
	}
}

OUTPUT

* 1 1 1 1 
o * 1 1 1 
o o * 1 1 
o o o * 1 
o o o o * 
Pattern 1 & 2

Pattern 5, 6 and 7

public class p1 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				System.out.print("*  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

*  *  *  *  *  
*  *  *  *  *  
*  *  *  *  *  
*  *  *  *  *  
*  *  *  *  * 
public class p2 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				System.out.print(i+"  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

1  1  1  1  1  
2  2  2  2  2  
3  3  3  3  3  
4  4  4  4  4  
5  5  5  5  5  
public class p4 
{
	public static void main(String[] args) 
	{
		for(int i=1; i<=5; i++)
		{
			for(int j=1; j<=5;j++)
			{
				System.out.print(j+"  ");
			}
		System.out.println();
		}
	}
}

OUTPUT

1  2  3  4  5  
1  2  3  4  5  
1  2  3  4  5  
1  2  3  4  5  
1  2  3  4  5

Thursday, 17 December 2020

Pattern 23 and 24

public class P23 {
	public static void main(String[] args) 
	{
		for(int i=1; i<6; i++)
		{
			for(int j=i; j<6; j++)
			{
				System.out.print(j + " ");
			}
			for(int k=1; k<i; k++)
			{
				System.out.print(k + " ");
			}
			System.out.println();
		}
	}	
}

OUTPUT

1 2 3 4 5 
2 3 4 5 1 
3 4 5 1 2 
4 5 1 2 3 
5 1 2 3 4 
public class P24 
{
	public static void main(String[] args) 
	{
		for(int i=5; i>0; i--)
		{
			for(int j=i; j<6; j++)
			{
				System.out.print(j + " ");
			}
			for(int k=1; k<i; k++)
			{
				System.out.print(k + " ");
			}
			System.out.println();
		}
	}
}

OUTPUT

5 1 2 3 4 
4 5 1 2 3 
3 4 5 1 2 
2 3 4 5 1 
1 2 3 4 5 

Friday, 11 December 2020

Armstrong numbers from 1 to 1000

public class Armstrong1to1000 {
	public static void main(String[] args) {
		System.out.println("Amstrong Numbers From 1 to 1000");
		int a,r;
		for(int i=1; i<=1000;i++)
		{
			a=0;
			int n=i;
			while(n!=0) 
			{
				r=n%10;
				a=a+r*r*r;
				n=n/10;
			}
			if(a==i)
			{
				System.out.println(i);
			}
		}
	}
}

OUTPUT:

Amstrong Numbers From 1 to 1000
1
153
370
371
407

Armstrong number using while loop

import java.util.*;
public class Armstrong {
	public static void main(String[] args) 	{
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		int reminder,amstrong=0,temp=n;
			while(n!=0)			
			{
				reminder=n%10;
				amstrong=amstrong+reminder*reminder*reminder;
				n=n/10;
			}
		if(temp==amstrong)
		{
		System.out.println("\n"+temp+" is an amstrong number");
		}
		else
		{
		System.out.println("\n"+temp+" is not an amstrong number");
		}
	}
}

OUTPUT 1:

Enter a Number: 
591

591 is not an amstrong number

OUTPUT 2:

Enter a Number: 
370

370 is an amstrong number

Armstrong number using For loop

import java.util.Scanner;
public class ArmstrongFor {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		int reminder,amstrong=0,temp=n;
			for(;n>0;)			
			{
				reminder=n%10;
				amstrong=amstrong+reminder*reminder*reminder;
				n=n/10;
			}
		if(temp==amstrong)
		{
			System.out.println("\n"+temp+" is an amstrong number");
		}
		else
		{
			System.out.println("\n"+temp+" is not an amstrong number");
		}
	}
}

OUTPUT:

Enter a Number: 
591

591 is not an amstrong number

OUTPUT 2:

Enter a Number: 
370

370 is an amstrong number

Armstrong number using Method

import java.util.Scanner;
public class ArmstrongMethod 
{
	void Amg(int n)
	{
		int reminder,amstrong=0,temp=n;
		while(n!=0)			
		{
			reminder=n%10;
			amstrong=amstrong+reminder*reminder*reminder;
			n=n/10;
		}
	if(temp==amstrong)
		System.out.println("\n"+temp+" is an amstrong number");
	else	
		System.out.println("\n"+temp+" is not an amstrong number");
	}
	public static void main(String[] args) 
	{
		AmstrongMethod obj = new AmstrongMethod();
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		obj.Amg(n);
	}
}

OUTPUT:

Enter a Number: 
591

591 is not an amstrong number

OUTPUT 2:

Enter a Number: 
370

370 is an amstrong number

Monday, 7 December 2020

Factorial of Number without User Interaction

public class FactorialWithoutUserInteraction 
{
	public static void main(String[] args) 
	{
		int fact=1;
			for(int i=1;i<=8;i++)
			{
				fact=fact*i;
			}
	System.out.println("\n Factorial of 8 is = "+fact);
	}
}

Output:

Factorial of 8 is = 40320

Factorial of Number using Method

import java.util.*;
public class FactMethod 
{
	void fact(int n)
	{
		int fact=1;
		for(int i=1;i<=n;i++)
		{
			fact=fact*i;
		}
	System.out.println("\n Factorial of "+n+" is = "+fact);
	}
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Number...");
		int number = s.nextInt();
		FactMethod obj = new FactMethod();
		obj.fact(number);
	}
}

Output:

Enter Number...
5

 Factorial of 5 is = 120

Factorial of Number using Do-While Loop

import java.util.*;
public class FactDoWhile 
{
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Number...");
		int number = s.nextInt();
		int fact=1,i=1;
			do
			{
				fact=fact*i;
				i++;
			}while(i<=number);
	System.out.println("\n Factorial of "+number+" is = "+fact);
	}
}

Output:

Enter Number...
6

 Factorial of 6 is = 720
 
 

Factorial of Number using While Loop

import java.util.*;
public class FactorialWhile 
{
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Number...");
		int number = s.nextInt();
		int fact=1,i=1;
			while(i<=number)
			{
				fact=fact*i;
				i++;
			}
	System.out.println("\n Factorial of "+number+" is = "+fact);
	}
}

Output:
Enter Number...
7

 Factorial of 7 is = 5040
 

Factorial of Number using Recursion

import java.util.*;
public class FactorialRecursion 
{
	int fact(int n)
	{
		if(n==0)
			return 1;
		else
			return(n*fact(n-1));
	}
	public static void main(String[] args) 
	{
		FactorialRecursion obj = new FactorialRecursion();
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Number...");
		int number = s.nextInt();
		int fact=1;
		fact = obj.fact(number);
	System.out.println("\n Factorial of "+number+" is = "+fact);
	}
}

Output:

Enter Number...
4

 Factorial of 4 is = 24

Factorial of Number using For Loop

import java.util.*;
public class Factotial 
{
	public static void main(String[] args) 
	{
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Number...");
		int number = s.nextInt();
		int fact=1;
			for(int i=1;i<=number;i++)
			{
				fact=fact*i;
			}
	System.out.println("\n Factorial of "+number+" is = "+fact);
	}
}

Output:

Enter Number...
3

 Factorial of 3 is = 6
 

Fibonacci Series using Recursion

import java.util.*;
public class FibRecursion {
	int fibSeries(int n){
		if(n<=1) 
		{
			return n; 
		}
		return fibSeries(n-1)+fibSeries(n-2);
	}
	public static void main(String[] args) 
	{
		Scanner scan = new Scanner(System.in);
		System.out.println("\n Enter Limit...");
		int N = scan.nextInt();
		FibRecursion f = new FibRecursion();
		f.fibSeries(N);
		for(int i=0; i<N; i++)
		{
			System.out.print(" " + f.fibSeries(i));
		}		
	}
}

Output:

Enter Limit...
10
 0 1 1 2 3 5 8 13 21 34



Fibonacci Series using Do-While Loop

public class fibDoWhile 
{
	public static void main(String[] args) 
	{
		int a=0,b=1,c,i=0;
		System.out.print("\n"+ a +" "+ b);
		do
		{
			c=a+b;
			a=b;
			b=c;
			System.out.print(" " + c);
			i++;
		}while( i<5 );
	}
}

Output:

0 1 1 2 3 5 8



Fibonacci Series using Method

public class FibMethod 
{
	void fib()
	{
		int a=0,b=1,c;
		System.out.print("\n"+ a +" "+ b);
		for(int i=0; i<5; i++)
		{
			c=a+b;
			a=b;
			b=c;
			System.out.print(" " + c);
		}
	}
	public static void main(String[] args) 
	{
		FibMethod obj = new FibMethod();
		obj.fib();
	}
}

Output:

0 1 1 2 3 5 8

Fibonacci Series using While Loop

public class fibUsingWhile 
{
	public static void main(String[] args) 
	{
		int a=0,b=1,c,i=0;
		System.out.print("\n"+ a +" "+ b);
		while( i<5 )
		{
			c=a+b;
			a=b;
			b=c;
			System.out.print(" " + c);
			i++;
		}		
	}
}

Output:

0 1 1 2 3 5 8



Fibonacci Series using For Loop

import java.util.*;
public class FibonacciSeries 
{
	public static void main(String[] args) 
	{
		int a=0,b=1,c;
		Scanner s = new Scanner(System.in);
		System.out.println("\n Enter Limit...");
		int size = s.nextInt();
		System.out.print("\n"+ a +" "+ b);
		for(int i=0; i<size; i++)
		{
			c=a+b;
			a=b;
			b=c;
			System.out.print(" " + c);
		}		
	}
}

Output:

Enter Limit...
10

0 1 1 2 3 5 8 13 21 34 55




Wednesday, 2 December 2020

Palindrome using Array

Write a Java Program to Check Whether a Array elements are Palindrome or Not  
import java.util.Scanner;
public class PalindromeArray 
{
public static void main(String[] args) 	
{
	Scanner scan = new Scanner(System.in);
	System.out.println("\nEnter how many nos u have to check:");
	int size=scan.nextInt();
	int numbers[] =new int[size];
	System.out.println("\nEnter Array of numbers to be checked");
	for(int i=0;i<size;i++)	
	{
		numbers[i] = scan.nextInt();
	}
	for(int i=0;i&ltnumbers.length; i++)	
	{
		int n1 = numbers[i];
		int reverseN1 = 0;
		int temp=0;				
		while(n1>0)	
		{
			temp =n1%10;
			n1=n1/10;
			reverseN1=reverseN1*10+temp;
		}
		if(numbers[i]==reverseN1) 
		{
		System.out.println("\n"+numbers[i]+ "  is pallindrome" );
		}
		else 
		{
		System.out.println("\n"+numbers[i]+ "  is  not a pallindrome");
		}
	}
}
}

Output
Enter how many nos u have to check:
5

Enter Array of numbers to be checked
123
4554
78987
951159
357357

123  is  not a pallindrome

4554  is pallindrome

78987  is pallindrome

951159  is pallindrome

357357  is  not a pallindrome


Palindrome using While Loop

Write a Java Program to Check Whether a Number is Palindrome or Not using While Loop  
import java.util.Scanner;
public class palindromeWhile 
{
	public static void main(String[] args) 
	{
		int reminder,reverse=0,temp;
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		temp=n;
			while(n>0)
			{
				reminder=n%10;
				reverse=reverse*10+reminder;
				n=n/10;
			}
		if(temp==reverse)
		{
			System.out.println("\n\n"+temp+" is a pallindrome");
		}
		else
		{
			System.out.println("\n\n"+temp+" is not a pallindrome");
		}
	}
}


Output
Enter a Number: 
456321

456321 is not a pallindrome


Palindrome Without User Interaction

Write a Java Program to Check Whether a Number is Palindrome or Not Without User Interaction  
public class ArrayPalindromeWithoutUserInteraction 
{
	public static void main(String[] args) 
	{
	int arrNumbers[] = new int[] {1441, 65, 22, 87, 121, 96358, 159951};	
	System.out.println("Array is\n{1441, 65, 22, 87, 121, 96358, 159951}");
	for(int i=0 ; i<arrNumbers.length;i++)
	{
		int n = arrNumbers[i];
		int reverseN = 0;
		int reminde=0;				
		while(n>0)
		{
			reminde =n%10;
			n=n/10;
			reverseN=reverseN*10+reminde;
		}
		if(arrNumbers[i]==reverseN)
		{
		System.out.println("\n"+arrNumbers[i]+ "  is pallindrome" );
		}
		else
		{
		System.out.println("\n"+arrNumbers[i]+ "  is  not a pallindrome");
		}
	}
	}
}

Output
Array is
{1441, 65, 22, 87, 121, 96358, 159951}

1441  is pallindrome

65  is  not a pallindrome

22  is pallindrome

87  is  not a pallindrome

121  is pallindrome

96358  is  not a pallindrome

159951  is pallindrome


Palindrome using Do-While Loop

Write a Java Program to Check Whether a Number is Palindrome or Not using Do-While Loop  
import java.util.Scanner;
public class PalindromeDoWhile 
{
	public static void main(String[] args) 
	{
		int reminder,reverse=0,temp;
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		temp=n;
			do
			{
				reminder=n%10;
				reverse=reverse*10+reminder;
				n=n/10;
			}while(n!=0);
		if(temp==reverse)
		{
			System.out.println("\n\n"+temp+" is a pallindrome");
		}
		else
		{
			System.out.println("\n\n"+temp+" is not a pallindrome");
		}
	}
}

Output
Enter a Number: 
99999

99999 is a pallindrome




Palindrome using For Loop

Write a Java Program to Check Whether a Number is Palindrome or Not using For Loop  

import java.util.Scanner;
public class PalindromeFor 
{
	public static void main(String[] args) 
	{
		int reminder,reverse=0,temp;
		Scanner scan = new Scanner(System.in);
		System.out.println("\nEnter a Number: ");
		int n = scan.nextInt();
		temp=n;
		for(;n!=0;)
		{
			reminder=n%10;
			reverse=reverse*10+reminder;
			n=n/10;
		}
		if(temp==reverse)
		{
			System.out.println("\n\n"+temp+" is a pallindrome");
		}
		else
		{
			System.out.println("\n\n"+temp+" is not a pallindrome");
		}
	}
}

Output 

Enter a Number: 
12321


12321 is a pallindrome




Pattern 31 & 32