Please answer numbers 1 2 and 3 Number 3 must be coded in Ja
(Please answer numbers 1, 2, and 3. Number 3 must be coded in Java. This question deals with palindromic dates-that is, dates that read the same forward and backward.)
1. The year 2002 was a palindromic year. When is the next palindromic year?
2. If dates are written MMDDYYYY, then May 2, 2050, is a palindromic date. What is the earliest palindromic date of the 21st century?
3. Create a program that identifies all palindromic dates in a given year. First, a user enters a year. Then the program reports the palindromic dates. Finally, the program asks the user if he or she wishes to try again. Notice that you need a Palindrome class that permits testing “digit” characters.
Solution
Q1- The Next Palindromic year will be 2112 and you can get all the palindromic year by executing this java code
import java.io.*;
class Date{
public static void main(String args[]){
Console con= System.console();
int num,r,sum,temp;
int min,max;
System.out.print(\"Enter min\");
min=Integer.parseInt(con.readLine());
System.out.print(\"Enter max\");
max=Integer.parseInt(con.readLine());
System.out.print(\"Palindrome numbers in given range are: \");
for(num=min;num<=max;num++){
temp=num;
sum=0;
while(temp!=0){
r=temp%10;
temp=temp/10;
sum=sum*10+r;
}
if(num==sum)
System.out.println(num);
}
}}
Q-2
In the mmddyyyy format, the first Palindrome Day in the current millennium (January 1, 2001 to December 31, 3000) was October 2, 2001(10-02-2001) and the last such day will be September 22, 2290 (09-22-2290). There will be 12 Palindrome Days in the 21st century in the mmddyyyy format.
