
add array in the code please
Question: Write bash script which only accepts a palindrome value in an array also print the length of the given value by the user and find the largest length palindrome word from the given values in an array
Expected Output:
Input a palindrome value: cat
Wrong input
Input a palindrome value: MOM
Correct it’s a palindrome the length of the given value is 3…
echo "Input a palindrome value:"
read str
for i in $(seq 0 ${#str}) ; do
revstr=${str:$i:1}$revstr #finding reverse of the str
done
if [ "$str" = "$revstr" ]; then #checking if reverse of str is equal to str
echo "Correct it’s a palindrome the length of the given value is ${#str}"
else
echo "Wrong input"
fi

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- In this project you will generate a poker hand containing five cards randomly selected from a deck of cards. The names of the cards are stored in a text string will be converted into an array. The array will be randomly sorted to "shuffle" the deck. Each time the user clicks a Deal button, the last five cards of the array will be removed, reducing the size of the deck size. When the size of the deck drops to zero, a new randomly sorted deck will be generated. A preview of the completed project with a randomly generated hand is shown in Figure 7-50.arrow_forward5. Calculate the means of the rows and assign it to a variable called x5 # YOUR CODE HERE raise NotImplementedError() assert (x5 np.array([ 2., 5., 8., 11., 14.])).all()arrow_forwardFor a resulting array what commands could you use to remove the first and last values of the array? Assuming it’s a Roa array, how could you add an extra value to the beginning of the array?arrow_forward
- Computer Science Must be an terminal/console UI Program. Java Menu Driven App Using Netbeans. Program Requirements: Make a complete program that has the ability to store and display integer values in an array. Add additional elements to the array using screen input. Remove array elements based on on-screen input. List all of the elements in the array and compute the sum of all the elements. List the even elements in the array and compute the sum of the even elements. List the odd elements in the array and compute the sum of the odd elements.arrow_forwardJava code pleasearrow_forwardUsing Java Write an app that allow data entry into an array. 1 Ask the user how many numbers they want to add. 2 Allocate an array of doubles to the specified size. 3 Prompt the user for the numbers to populate the array. 4 Calculate the total and the average of the values.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





