Java Reference
In-Depth Information
System . out . println ( "Fahr Centigrade" );
}
protected
protected void
void end () {
System . out . println ( "-------------------" );
}
}
C:\javasrc\numbers> java numbers.TempConverter2
Fahr Centigrade
-40.00 -40.00
-30.00 -34.44
-20.00 -28.89
-10.00 -23.33
0.00 -17.78
10.00 -12.22
20.00 -6.67
30.00 -1.11
40.00 4.44
50.00 10.00
60.00 15.56
70.00 21.11
80.00 26.67
90.00 32.22
100.00 37.78
110.00 43.33
120.00 48.89
Program: Number Palindromes
My wife, Betty, recently reminded me of a theorem that I must have studied in high school
but whose name I have long since forgotten: that any positive integer number can be used to
generate a palindrome by adding to it the number comprised of its digits in reverse order.
Palindromes are sequences that read the same in either direction, such as the name “Anna” or
the phrase “Madam, I'm Adam” (ignoring spaces and punctuation). We normally think of
palindromes as composed of text, but the concept can be applied to numbers: 13531 is a pal-
indrome. Start with the number 72, for example, and add to it the number 27. The results of
this addition is 99, which is a (short) palindrome. Starting with 142, add 241, and you get
383. Some numbers take more than one try to generate a palindrome. 1951 + 1591 yields
3542, which is not palindromic. The second round, however, 3542 + 2453, yields 5995,
Search WWH ::




Custom Search