
Write a C++ Program
String Processing: Use the string processing functions we covered in class (length(), size(), find( ), substr( ), at( ), erase( ), insert( ), replace( ) and append in the problems below. Remember if you need to reset a file to the beginning you can use infile.seekg(0, ios::beg);
1.0 Given the text file UAH_sample.txt(details below) write a program that performs the following tasks:
- Find and count all words that are from 1 to 10 letters long. Print the results to the screen as a table.
- Special circumstances:
- You should not count punctuation at the end of the sentence as part of the word. Just erase the punctuation or subtract 1 from the length.
- Do not count numbers as words.
- You do not need to remove apostrophes. Just count that as part of the length.
- Multiple words connected by dashes, like state-of-the-art, can be counted as one long word.
- Special circumstances:
Count the number of times each letter (A_Z, a-z) appears in the file. Print (to the screen) a table of each letter and the number of times it appears. You do not need separate counts for upper and lowercase. Ignore all characters that are not letters.
- Given an input letter find and print to the screen all words that begin with that letter. Check for both uppercase and lowercase letters beginning a word. Show results for letters a, r and u.
- Using the original UAH_sample.txt file replace each occurrence of UAHuntsville with UAH. Create a new file with the updated text. Upload the new file to canvas along with your other documents.
UAH_sample.txt - Being a Charger is about more than just fitting in; it's about standing out and being a leader on campus and in the community. To help, we've created a strong leadership program to enable you to excel outside of the classroom and make a smooth transition from collegian to careerist skills you can also learn by joining one of UAHuntsville's many student-run organizations or holding a position in the Student Government Association. No matter what role you choose, at UAHuntsville your student experience is just as valuable as your education.

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

- Write a C program to read in a text file and provide a count ofa. The number of strings in the file, where a string begins with anon–white space character and ends with a white space character.b. The number of words in the file, where a word begins withan alphabetic character (e.g., a–z or A–Z) and ends with anonalphabetic character.c. The number of unique words in the file. Words are as defined inpart b. The set of unique words has no duplicates.d. The frequency of words in order of most frequent to least frequent.In other words, analyze the text file, count the number of times eachword occurs, and display these counts from most frequent word toleast frequent.arrow_forwardWrite a program (in C programming) cylinder.c that accomplishes the following: Read a list of radii and heights from a file(cylinder_input.data). For each pair of values, calculate the cylinder's volume and surface area. Display the results on the screen and save the results to a file. File: cylinder_input.data 1.5 10.2 2.21 20 3 30.243 55.23 2.2 12.1 45.989 The contents of the output file “cylinder_output.data” 1.500000 10.200000 72.099551 110.269902 2.210000 20.000000 306.877054 308.404496 3.000000 30.243000 855.100680 626.615787 55.230000 2.200000 21082.525775 19929.377237 12.100000 45.989000 21153.127133 4416.305811arrow_forwardWrite a program called p1.py that contains a function called filereader() that takes a number n (int) and a filename (string) as input. The function should read and store every nth line of the file in a list and return it.Test your function inside the main function (don’t forget the main guard).Sample output with “samplefile_t8.txt” file. It contains the following lines of text.kangaroo, 5capybara, 7wombat, 2koala, 3wallaby, 4quokka, 5platypus, 9dingo, 2kookaburra, 1>>> filereader(“samplefile_t8.txt”, 3) returns[“wombat, 2”, “quokka, 5”, “kookaburra, 1”]arrow_forward
- Assume that you are designing a simple text editor (like Notepad) that supports inserting text, copy, paste and editing for any size file (including book-length files). Between the String objects and StringBuffer objects, which one is more appropriate and why? O String, because StringBuffer is read-only String, because it will execute more efficiently String, because only simple operations are needed StringBuffer, because it allows for changing the characters stored in the object StringBuffer, because it has copy and paste methodsarrow_forwardIn Python.arrow_forwardWrite a program called p2.py that has the following functionality:1. read input from a file containing a list of words (each word is written on its own line) andstore the data (strings) in a listHint: try using the readline() function or a for loop2. randomly select a string from the list3. output / write the selected string to a new filearrow_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





