Question: Design a program that checks whether a string is a palindrome. The string can be several words or just a single word: Acme Palindrome Finder

Design a program that checks whether a string is a palindrome. The string can be several words or just a single word:

Acme Palindrome Finder

Enter a string to check: Was it a rat I saw?

Analyzing input. Please wait

Your input: Was it a rat I saw

Reverse input: was I tar a ti saW

Congratulations! Palindrome found!

ESET 269 Laboratory #4 Fall 2018 Minimum Requirements:

Your program should pick a random number from 3 to 7 and wait that many seconds before displaying the results. Use functions from the time.h library to get the current time. Use a loop to query the system clock until the desired number of seconds have passed.

NOTE:You can use the wait() function code shown in class, or you can use a delay function of your choice.

The input should not be case sensitive.

The program should work with numbers as well as letters.

White space is not part of a palindrome, as you can see in the above example. Your algorithm should remove white space to check for a palindrome, but the final display should simply reverse the original string (keeping the white space intact).

Procedure Dont code.

Be sure to come up with a plan first using human language / pseudo-code. Only when you know you have a solid algorithm should you consider to write code.

Remember the Programmer Productivity Paradox: The more time you spend on Step #2, the quicker you will complete the whole project and this lab successfully. Think for a moment how you would implement this.

First, write generic, high-level steps with little or no detail. These steps describe basically what your program will do. To get you started, an example of this step is done for you below: 1) Print the program title and instructions on the screen.

2) Get user input

3) Print Please wait on the screen. a. Delay a random number of seconds from 3 to 7. b. Print a . on the same line as Please wait each second that passes.

4) Make a working copy of the input string.

5) Remove punctuation and white space from the working copy. Make all letters uppercase.

6) Analyze the copy for a possible palindrome. a. ? b. ? ESET 269 Laboratory #4 Fall 2018

7) Print the original input string forwards and backwards.

8) Display whether the string is a palindrome.

Next, write more detailed operations between the high-level steps. These operations describe how your program will work. If they havent made themselves obvious already in Step 1, youll identify where you should use loops in this step. Hint: Youll probably need a loop for the Please wait delay. Youll also likely want to use a loop for processing the string, and youll want another loop for the palindrome analysis algorithm.

Consider what the program must keep track of (e.g. user input, temporary string for processing and analysis, indexing, etc.) Declare variables accordingly.

Dont forget error-checking and error prevention in your plan. For example, would it be possible for the user to enter a string that is longer than the size of your character array youre using to store it? What if the user enters a blank line?

Code

Begin writing valid C statements to do what the pseudo-code describes. Dont delete your pseudocode. It should remain in your code as helpful commentary for others to follow your intentions (and for you to remember what your code is supposed to do).

Hint: To force scanf() to read in multiple words the user types, use the following format specifier: scanf(%[^ ]s, myString); Translation: Store all characters typed in except (^) the newline ( ). Loops: Make your program count Nearly every program needs to count somewhere in the algorithm. A counter can keep track of items (e.g. number of times the word code appears in this document), or more often it is simply counting how many times a loop has looped.

For example: // METHOD 1: USING A FOR() LOOP int x; // declare the variable to do the counting // start at zero, keep doing the following as long as x is less than 10, increment x each time through for (x=0; x < 10; x = x +1) { // do something } Another (shortcut) way to increment using the ++ operator: ++x; // increment the counter by one ESET 269 Laboratory #4 Fall 2018 Or x++; // increment the counter by one

// METHOD 2: USING A WHILE() LOOP int x; // declare the variable to do the counting x = 0; // start at zero (initialize the variable) // keep doing the following as long as x is less than 10 while (x < 10) { // do something x = x + 1; // increment the counter by one } Check your Output o Works with numbers and letters o Works with mixed case letters o Ignores punctuation in the input o Works with a single word or several words o Displays the user input string forwards and backwards, with the first characters lined up in the same column

In C (eclipse)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!