Академический Документы
Профессиональный Документы
Культура Документы
Requirements
You will need to read and understand Java tutorial pages. You can use the following pages
or your can look for other material in the Web.
While Statements:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html
If statements:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
Introduction: The program template represents a complete working Java program with
one or more key lines of code replaced with comments. Read the problem description and
examine the sample output, then study the template code. Using the problem-solving tips
as a guide, replace the /* */ comments with Java code. Compile and execute the program.
Compare your output with the sample output provided. Then answer the follow-up
questions. The source code for the template is available below the problem.
What is Palindrome? How to find the Palindrome: You must watch this video:
1
CSC 110 Software Design and Programming I
https://youtu.be/2-TKmwzxtZ8
Program Template
1 //Palindrom
publ e.java
ic class Palindrom e
2 //Program tests for a palindrom e
{
3 im port java.ut
//checks ifila.Scanner;
5-digit num ber is a palindrom e public
4 void checkPalindrom e()
5 {
6 Scanner input = new Scanner( System .in );
7
8 int num ber;//user input num ber int
9 digit1;//fi rst digit 2
10 int digit2; // second digit int
11 digit4; // fourth digit int digit5; //
12 fifth digit
13 int digits; // num ber of digits in input
14
16 digits = 0;
17
18 /* W rite code that inputs a fi ve-digit num ber.D isplay an error m essage
19 if the num ber is not fi ve digits.Loop untila valid input is received.*/
CSC 20 110 Software Design and Programming I
21 /* W rite code that separates the digits in the fi ve digit num ber.U se division to isolate
22 the left-m ost digit in the num ber,use a rem ainder calculation to rem ove that digit
23 from the num ber.Then repeat this process.*/
24
25
/* W rite code that determ ines w hether the fi rst and last digits are identical and
26
Fig277.2 PalindromeTest. Java and Fourth digits are identical.O utput w hether or not the original
the second
string is a palindrom e.*/
128 // PalindromeTest.java
229 // Test} application
// end m ethodfor class Palindrome
checkPal indrom e
330 public
} /class
/ end PalindromeTest
class Palindrom e
431 {
532 public static void main( String args[] )
633 {
734 Palindrome application = new Palindrome();
835 application.checkPalindrome();
9 } // end main
10 } // end class PalindromeTest
Sample Output
3
CSC 110 Software Design and Programming I
Problem 1
Source code of your Problem1: Palindrome and PalindromeTest classes.
Screen shots of a sample execution.
A report that explains how your class works and observations you may have from the
execution of PalindromeTest, as well as things that may have been surprising.
Explain what tests you run in order to make sure that the methods you introduced
worked correctly.
Explain any challenged encountered and how you overcome the challenges
Problem 2
Source code of your Palindrome2 and Palindrome2Test classes.
Screen shots of a sample execution. .
Explain what tests you run in order to make sure that the methods you introduced
worked correctly.