On This Page
Overview
A palindrome is a number or a text phrase that reads the same backwards as forwards. A decimal palindrome is a special case of a palindrome, where the left side of the decimal point is reversed from the right side of the decimal point. For example, the numbers 12345.54321 and 23232.23232 are decimal palindromes, but the number 12345.23456 is not.
Sample Output and Operation
Enter a 10-digit number with a
decimal point in the middle:
12345.54321
12345.54321 is a decimal palindrome!!!
Another number (Y/N)? y
Enter a 10-digit number with a
decimal point in the middle:
12345.65432
12345.65432 is not a decimal palindrome.
Another number (Y/N)? n
^ top
Specifications
Write an application named DecimalPalindrome that prompts the user and reads a ten digit number from the command line. With the decimal point in the middle, the user enters a total of eleven characters. The program then reports whether or not the number entered is a valid decimal palindrome.
Use the following code to get started. Do not change the names of the methods in the starter code, though you may add more methods if you like.
import java.io.*;
/**
* CS-20J Asn02
* DecimalPalindrome.java
* Purpose: Tests user input for a decimal palindrome.
*
* @version 1.0 9/07/03
* @author Your Name
*/
public class DecimalPalindrome {
/**
* The main method contains all user input and output.
*
* @param args Not used.
* @throws IOException If an input or output exception occurred.
*/
public static void main(String args[]) throws IOException {
double number = 0; // user input number
boolean valid = isDecimalPalindrome(number);
if (valid) {
System.out.println(number + " is a decimal palindrome!!!");
} else {
System.out.println(number + " is not a decimal palindrome.");
}
}
/**
* Checks if number is a decimal palindrome.
*
* @param number The number to check.
* @return true if number is a decimal palindrome, otherwise false.
*/
public static boolean isDecimalPalindrome(double number) {
return false; // change this line
}
}
Additional specifications:
- The
isDecimalPalindrome method checks whether a double number is a valid decimal palindrome.
- Do not put any user input or output code in the
isDecimalPalindrome method.
- Use a loop to allow the user to keep entering more numbers for checking until they decide to quit.
- You may assume that users will only enter valid data types and numbers of the correct length.
- Note that rounding errors can occur when using floating-point numbers such as doubles. You must deal with rounding errors when processing and evaluating the decimal numbers entered by users to ensure decimal palindromes are evaluated correctly.
- The program must pass all test cases for full credit.
- You must document and organize your code following the requirements in the How To Document and Organize Java Code. Note that jEdit can automatically check many items of your programming style to help you locate problems.
- Do not put your code into a package at this time.
^ top
Test Cases
Testing is an important part of software development. Usually, programmers develop tests for each unit of code they produce. This is know as "unit testing" and allows the programmer to verify that the code they develop works correctly.
To assist you in developing your code, I provide tests for this assignment. These tests, known collectively as "test cases", help to make sure that your assignment meets its requirements. I will use these test cases (and perhaps others) to test your assignment, and you should too. If the test cases do not pass, then you will lose points for the assignment.
Install the tests by copying the following file into the same directory as your .java source code files:
Run the tests as you would any other Java program. You will need to compile your source code before compiling and running the test code.
^ top
Extra Credit
The following are worth extra credit points:
- Add code to check if the user enters incorrect data types. For instance, if the user enters an 'A' when prompted for a decimal number. (1 point)
- Install jEdit and use it to check your programming style. Document your installation experience. (1-2 point)
- Run the Javadoc utility and submit Javadoc files for your program. (1-2 points)
Make certain that your README.txt file lists any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course Syllabus.
Compilation
- 2: Program compiles without error
- 0: Program does not compile
Functionality
- 8: Demonstrates mastery of the assignment
- Has extra features or demonstrates techniques beyond the assignment
- Applies concepts from the lesson(s) appropriately
- Meets all specifications with particularly elegant solutions
- All errors are caught and users protected from unfriendly messages
- 6: Has all the major functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Meets all specifications
- Implementation seems more complicated than necessary.
- May have one minor error
- 4: Has much of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets all but one of the specifications
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- 2: Serious functional problems but shows some effort and understanding
- Meets at least 1/2 of the of the specifications
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- 0: Does not function
User Input
- 4: User input is easy and graceful
- Instructions to the user are clearly stated
- All input is thoroughly checked
- Error messages clearly explain how to fix problems
- 3: User input requires some unnecessary effort
- Instructions to the user are occasionally confusing
- All input is checked but some minor conditions were missed
- Error messages somewhat explain how to fix the problem
- 2: User input is tiresome or annoying
- User input instructions are sometimes confusing
- All input is checked but many conditions were missed
- Error messages are somewhat vague
- 1: User input is very difficult
- User input instructions are usually confusing
- Some input is not checked
- Error messages are confusing
- 0: Does not run
Programming Style
- 4: Code is well-documented
- Name, date, and page description in opening comment block
- Specified class names are used
- Comment block at start of every function
- Proper use of whitespace and indenting
- Descriptive variable names
- Meets all requirements in How To Document and Organize Java Code
- 3: Code has minor documentation errors
- 2: Code has some documentation errors
- 1: Code has many documentation errors
- 0: No apparent attempt to document code
REAME.txt File
- 2: README.txt file submitted with specified information included
- 1: README.txt submitted but some information was not included
- 0: No README.txt submitted
Maximum Score: 20, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
DecimalPalindrome.java
- Any other source code needed to make your program function
- Any files needed for extra credit work, if applicable
You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.
^ top
Home
| WebCT
| Announcements
| Schedule
| Expectations
| Syllabus
Help
| FAQ's
| HowTo's
| Links
Last Updated: September 23 2003 @17:23:12
|