Lab 12B: Palindromes with Files
Overview
This is a demonstration of reading and writing fil...
Computers and Technology, 22.04.2021 18:50 jadbaubl1449
Lab 12B: Palindromes with Files
Overview
This is a demonstration of reading and writing files.
Objectives
Be able to read from an input file, perform string manipulation on each line of the file, and write to an output file.
Provided input file:
A single input file named something like myinput. txt is provided that contains a few lines of text.
Description
Create a program to read each line of an input file, determine if the text on the line is a palindrome, and write "palindrome' or 'not a palindrome' to the output file depending on the input. Recall from lab 16.23 that a palindrome is a word or a phrase that is the same when read both forward and backward. In this program, you need to ignore spaces when determining if a phrase is a palindrome. Examples are: 'bob," "sees," or "never odd or even" (ignoring spaces).
You will read the line from a text file, use a function called palindromeChecker to determine if the line is a palindrome. Your function should take a string and return either the string palindrome or not a palindrome, as applicable.
You will write the results to a text file and display the results to the user as shown below.
You may refer to labs 8C and 13B and reuse your code from those labs, as applicable.
Sample Output to the file from the Provided Input File
palindrome
palindrome
not a palindrome
palindrome
not a palindrome
palindrome
Sample Output to the User from the Provided Input File
bob ==> palindrome
sees ==> palindrome
over the moon ==> not a palindrome
never odd or even ==> palindrome
statistics ==> not a palindrome
dr awkward ==> palindrome
Answers: 1
Computers and Technology, 22.06.2019 19:20, mayaparness
Write a program that prompts the user to input a string. the program then uses the function substr to remove all the vowels from the string. for example, if str = "there", then after removing all the vowels, str = "thr". after removing all the vowels, output the string. your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.
Answers: 2
Computers and Technology, 23.06.2019 21:30, shadoris26
To move a file or folder in microsoft windows, you can click and hold down the left mouse button while moving your mouse pointer to the location you want the file or folder to be, which is also known as.
Answers: 3
Computers and Technology, 23.06.2019 23:40, dudedude1593
Which of the following calculates the total from the adjacent cell through the first nonnumeric cell by default, using the sum function in its formula? -average -autosum -counta -max
Answers: 1
Computers and Technology, 24.06.2019 12:30, stephanieanaya7
Why does the pc send out a broadcast arp prior
Answers: 1
Social Studies, 12.04.2020 04:01
English, 12.04.2020 04:01
Mathematics, 12.04.2020 04:01
History, 12.04.2020 04:01
Mathematics, 12.04.2020 04:01
Mathematics, 12.04.2020 04:01
Mathematics, 12.04.2020 04:01