Upload files to "OOP/Java/Lab/Week1"
This commit is contained in:
parent
24683dac5a
commit
8542582101
5 changed files with 101 additions and 0 deletions
24
OOP/Java/Lab/Week1/Palindrome.java
Normal file
24
OOP/Java/Lab/Week1/Palindrome.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
class Palindrome
|
||||
{
|
||||
public static void main(String args[])
|
||||
{
|
||||
int a,i,c,temp,rev;
|
||||
a = Integer.parseInt(args[0]);
|
||||
|
||||
temp = a;
|
||||
rev = 0;
|
||||
|
||||
while(temp!=0)
|
||||
{
|
||||
c = temp%10;
|
||||
rev = rev*10 + c;
|
||||
temp = temp/10;
|
||||
}
|
||||
|
||||
if(rev == a){
|
||||
System.out.println("The number is a palindrome.");
|
||||
}else{
|
||||
System.out.println("The number is not a palindrome.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue