Homework 2, Notlob?.

Short Description:

Write a program that classifies strings as palindromes.

This assignment is worth 20 points.

Goals

When you finish this homework, you should: The main goal of this assignment is to make sure you can manipulate strings.

Formal Description

Write a program which reads phrases from a file and classifies the phrases as one of the following:

Your program should begin by requesting the name of the input file with the following prompt:

Enter the file name =>
Note, this prompt does not include the newline character. However, after you have read the file name, please print a newline character.

If the file does not exist, your program should print the following message and exit:

The file XXXXXXX does not exist.
Where XXXXXXX is the given file name.

If this file exists it will contain one phrase per line. Your program should read each phrase from the file. The program should then classify the phrase as a palindrome according to the above definitions. Finally the program should print the phrase, in quotation marks, followed by the words is a , the classification and a period. The phrase should be printed exactly as it was in the file and the classification should be all lower case.

For example, if the input file contains:

racecar
god saw I was dog
I did, did I?
Able was I ere I saw Elba.
A man, A plan, A canal: Panama!
Madam, I'm Adam.
Hello World!
spam

The output should be:

Enter the file name=> input.txt

"racecar" is a perfect palindrome.
"god saw I was dog" is a perfect palindrome.
"I did, did I?" is a natural palindrome.
"Able was I ere I saw Elba." is a natural palindrome.
"A man, A plan, A canal: Panama!" is a palindrome.
"Madam, I'm Adam." is a palindrome.
"Hello World!" is a non-palindrome.
"spam" is a non-palindrome.

Discussion

Required Files

The all source code required to perform the task described above.

Your tar file must contain

Your tar file may contain Your tar file MUST NOT contain

Submission

Submit a tar file as an attachment to an email message to dbennett@edinboro.edu by class time on the due date.

The subject of this message should be CSCI 230 Homework 2 Submission.