View the step-by-step solution to:

Question

JAVA PROGRAMMING ONLY

Please follow all the instructions and guidelines in the document.

Make sure you provide all the documents in the submission section as part of the solution. In summary, please follow every instructions in the pdf in order for me to accept the answer. Thanks.

Asst. 4 : Palindrome parsing CPSC 1150-005/006, Spring 2017 Instructor: A. Goldberg Langara College Preparation Familiarity with the following textbook sections and lectures will help you complete the assign- ment. You are also expected to attempt the exercises below before beginning the assignment. This assignment is intended to be done with a partner! Textbook sections 4.3, 4.4 5.2, 5.3, 5.6 Most relevant lectures L8, L9 Exercises 1. Read through the entire assignment! 2. What is a palindrome? If you don’t know, look it up. Google is your friend. 3. Write an algorithm to solve the Part A: Two-character problem. 4. Write an algorithm to solve the Part B: Digits only problem. 5. Using the algorithm you just wrote as a starting point, write an algorithm (in pseudocode) to solve the Part C: A real sentence problem. Trace through your algorithm to verify whether “Madam, I’m Adam.” is accepted as a palindrome. (It should be.) You will be required to submit this. Introduction You will be writing a program to test whether or not various user-entered String s of text are palindromes. You will start with a simpler version of this program, and gradually upgrade it until you arrive at a full solution. Pair programming You are encouraged to work in pairs for this assignment, and learn the practice of pair programming ! Introduce yourself to somebody in the class and ask to work together. (If you truly insist on working alone, you may.) Each pair should only submit one copy of the assignment (to one partner’s D2L account), with both of your names and IDs in the ±les. Pair programming works like this: The partners assume different roles. Once the algorithm has been developed and agreed upon, one partner will be the programmer (sitting at the keyboard, typing), and the other partner will observe what is typed. The second partner’s job is to catch syntax/logical errors as they occur, and to make suggestions to the programming partner. Every so 1
Background image of page 1
Asst. 4 : Palindrome parsing CPSC 1150-005/006, Spring 2017 Instructor: A. Goldberg Langara College often, the two partners should exchange roles. This technique has been proven to be very effective at producing better code. 1 Specifcations and instructions A reminder oF good practices Declare all your variables at the top of your main method, before any other statements. Use in-line comments carefully to explain what you are doing. Make sure each comment is useful. There is no need to comment every line. Obvious comments like //prints output are fairly useless. Concise but descriptive comments like //displays the largest number in numList are much more useful. Especially when there is tricky logic involved, be sure to explain it clearly. Comment your ending braces, i.e., //end outer while . Align your ending braces with the opening if or public or while that begins that block. Code inside a block should be uniformly indented by one level. 1.1 Part A: Two-character In this part, you will write a program called PalChecker , which tests whether or not a two character String is a palindrome. Do not proceed to Part B until Part A works properly. Input: The user should input a two character String . Don’t worry about improper input. Output: Sample console if the entered String is a palindrome: Please enter two characters: mm You entered a palindrome! Sample console if not: Please enter two characters: 3f Sorry , that is not a palindrome. 1.2 Part B: Digits only In this part, you will modify PalChecker to test whether or not any integer is a palindrome. The integer may have arbitrarily many digits. You will overwrite your earlier program. Do not proceed to Part C until Part B works properly. Hint: You will need to use a loop in this part. Input: The user should input an integer. Don’t worry about improper input. (Hint: You will likely want to treat the input as a String .) Output: Sample console if the entered integer is a palindrome: 2
Background image of page 2
Show entire document
Sign up to view the entire interaction

Top Answer

View the full answer
output0.jpeg

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online