In this lab, you will write a program that discovers prime numbers that are also palidromes.
Typically palindromes are thought of as phrases that are the identical whether they are read forwards or backwards. Most often, spaces and punctuation are ignored when evaluating whether or not a phrase is a palindrome. For example, "I prefer pi" is a palidrome since the sequence of letters is exactly the same regardless of whether you start at the beginning and move forward or start at the end and move backward.
For this assignment, you should write a program that displays all of the prime numbers between 1 and one billion that are palidromes and the total number of primes in this range that are palidromes.
For example, 3, 10501, and 31513 are all palidromes and prime.
The following classes may be useful: String, StringBuffer, and Integer. The Java documentation may be helpful for finding methods from these classes that aid you in your solution.
If you are looking for some additional fun, you could complete the assignment for binary, octal, and/or hexidecimal (base 2, 8, and/or 16) numbers too.
Here is a template file to use as a starting point for this report.
The lab report does not need to be self-contained. Your report should include:
As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost.
Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.
This laboratory assignment was developed by Dr. Chris Taylor.
| © 2001-2007 Dr. Christopher C. Taylor | Office: CC-36C | Phone: 277-7339 |