-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathThree_Function.java
More file actions
53 lines (52 loc) · 884 Bytes
/
Three_Function.java
File metadata and controls
53 lines (52 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.Scanner;
class One
{
One(int num)
{ int temp;
int rev=0;
while(num>0)
{temp=num%10;
num=num/10;
rev=rev*10+temp;
}
System.out.println("\nReversal is: "+rev);
}
}
class Two extends One//extends One
{
Two(int num)
{
super(num);
for(int i=2;i<num/2;i++)
{if(num%i==0){System.out.println("\nNot a Prime Number"); return;}}
System.out.println("\nPrime Number");
}
}
class Three extends Two
{
Three(int num)
{
super(num);
int temp,save=num;
int rev=0;
while(num>0)
{temp=num%10;
num=num/10;
rev=rev*10+temp;
}
if(rev==save)
{System.out.println("\nPalindrome\n");}
else
{System.out.println("\nNot a palindrome\n");}
}
}
class Four
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.println("\nEnter a number: ");
int num=sc.nextInt();
Three obj3=new Three(num);
}
}