Cash-back offer from May 2nd to 7th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 18.00

CSE205 Summer 2017 Assignment 1 | Complete Solution

Question posted by
Online Tutor Profile
request

CSE205 Summer 2017 Assignment 1

This is a simple review assignment and should be able to be completed easily. Be sure to follow all style and documentation requirements for THIS class. You will be penalized for not following these requirements.


In this assignment, you are to determine if an input string is a palindrome and, if it is, what type of palindrome. A palindrome for this assignment is defined as “a number, word or phrase consisting of alphanumeric characters that reads the same frontwards and backwards while ignoring case, punctuation and white space”.


For this assignment, create a package named assign1 and name your file Assign1.java.
UML Class Diagram
Notes on the UML Class Diagram
There is only one class, Assign1.
Underlining the name of the variable/method in a UML class diagram indicates that the variable or method is static. This means that all methods are static.
There are no class level variables.
The main is public while the other methods are private.
Limitations on Java Classes
For this assignment, you are limited to the following Java library classes.
1. Scanner
2. String
3. Character
Assign1
+ main (String []): void
- getInputLine (): String
- isPalindrome (String): boolean
- isEmptyLine (String): boolean
- getPalType (String): String
Required main function: Here is the main method. Copy this into your code and do not change it.
public static void main (String [] args) {
String line = getInputLine();
while (!isEmptyLine (line)) {
if (isPalindrome (line))
System.out.println ("\"" + line +
"\" is a palindrome and a " + getPalType (line));
else
System.out.println ("\"" + line + "\" is not a palindrome");
line = getInputLine();
}
System.out.println ("End of program");
}
Required methods: You must write the following methods as specified to complete your program. Pay attention to the name, return type and parameters.
public static String getInputLine ( )
Prompt the user to input a line of input and then read and return the line.
public static boolean isEmptyLine(String str)
Return true if the parameter is empty or false otherwise.
public static boolean isPalindrome (String str)
Return true if the string is a palindrome or false otherwise. See the pseudo-code on the next page for the logic and the restrictions on this implementation.
public static String getPalType (String str)
Determine the type of the palindrome and return “word”, “phrase”, or “number”.
The definition is
number: only digits with white space and/or punctuation
word: only alphabetic with no white space and/or punctuations
phrase: anything else.
isPalindrome pseudo-code
Note: in the following, the symbol  represents assignment
left  0
right  position of last character in string
okay  true
while okay and left < right
ch1  character in the string at position (left)
if ch1 is not a digit or letter
increment left
else
ch2  character in the string at position (right) right 4
okay true
ch1 1
ch2 1
12321 1Ab1
0
3
true
if ch2 is not a digit or letter
decrement right
else
convert both ch1 and ch2 to upper case
if ch1 = ch2
increment left
decrement right
else
okay  false
endif
endif
endif
end while
return okay
Coding Restrictions
1. You may NOT return from or break from the inside of a loop.
2. You may NOT copy the String to another String.
3. You must STOP processing as early as possible (when you find that it is or is not a palindrome).
Submitting
Using the link on Blackboard, submit your Assign1.java file for grading. It will be downloaded, compiled and graded as well as checked against the online utility to check for plagiarism and similarity to other students’ work.
Sample input and output
Enter a line of input: This is a test
“This is a test” is not a palindrome
Enter a line of input: 12345.4321
“12345.4321” is a palindrome and a number.
Enter a line of input: Otto!
“Otto!” is a palindrome and a phrase.
Enter a line of input: Able was I, ere I saw Elba.
“Able was I, ere I saw Elba.” is a palindrome and a phrase.
Enter a line of input: Abba
“Abba” is a palindrome and a word.
Enter a line of input:
Program complete

Available Answer
$ 18.00

[Solved] CSE205 Summer 2017 Assignment 1 | Complete Solution

  • This solution is not purchased yet.
  • Submitted On 25 May, 2017 12:05:24
Answer posted by
Online Tutor Profile
solution
This Tutorial is rated A+ previously,if yo...
Buy now to view the complete solution
Other Similar Questions
User Profile
AceTu...

CSE205 Summer 2017 Assignment 1 | Complete Solution

This Tutorial is rated A+ previously,if you have any questions regarding this tutorial than you can contact me. Check your E-mail inbox to download your solution document....

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35