Homework 3 Project 1, Notlob?.

Short Description:

Write a program that classifies strings as palindromes.


When you finish this homework project, 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:

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!

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.