Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

uwu part 0: Let's call a string containing the characters uwu an adorable string. When testing a string for adorability, it does not matter whether

image text in transcribed

image text in transcribed

image text in transcribed

uwu part 0: Let's call a string containing the characters "uwu" an adorable string. When testing a string for adorability, it does not matter whether or not the characters u, w, and u appear side-by-side, so long as they appear in that order. "uwu" is an adorable string, as is "uwuwu", but "wuu" and "uuw" are not adorable strings. Also, though, "uxwxu" is considered an adorable string, since although the characters u, w, and u are separated by the character 'x', they still appear in the string in the proper order. Strings count as adorable regardless of the case of the characters: "UwU" is adorable, as are "uWu" and "UWu". Write a function called adorability Tester that takes a string as a parameter, and returns a bool indicating whether or not that string is adorable. Write a main function that asks the user for a string, then calls adorability Tester to determine whether that string is adorable. Follow the output format below exactly: Type the string you would like to test: This string [is/is not] adorable. Uwu part 1: Write a program that reads a file containing a string on each line, and prints: How many strings are in the file How many of these strings are adorable The adorability value of the file as a whole, expressed as a floating-point number between 0 and 1. For example, if 7 out of 10 strings in the file are adorable, the adorability value of the file is 0.7 Follow the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability value of [filename] is (adorability value] uwu Part 2: Let's call the adorability count of a string as the number of occurrences of u, w, and u in that order in the string. The string "uwu" has an adorability count of 1, the string "Owo" has an adorability count of 0, and the string "did you watch naruto?" has an adorability count of 1, because the letters u, w, and u appear in that order. However, the string "do you want to run like naruto?" has an adorability count of 2: the first occurrence of uwu consists of the u in "you", the w in "want", and the u in "run", while the second occurrence of uwu consists of the u in "you", the w in "want", and the u in "naruto". The string "uwu uwu" has an adorability count of 6. I've indicated each adorable substring with underlines: uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu uwu Write a function called adorabilityCounter that takes a single string as input, then returns its adorability count. Write a main function that asks the user for a string, then calls adorabilityCounter to determine whether that string is adorable. Follow the output format below exactly: Type the string you would like to test: This string's adorability count is [count] NOTE: In terms of algorithm design, this is the most difficult part of the problem. Write out your strategy on paper and step through it (pretend you're the computer) before you try to implement it in code. Verify to the best of your abilities that your solution is indeed correct. If you try to write this in C++ without thoroughly verifying your algorithm on paper first, you will almost certainly not be able to find a valid solution. There are both recursive and non-recursive solutions to this question. I will give a small amount of extra credit if you implement this using a recursive function. Also, if you implement this using recursion, you may have an easier time on a future assignment. NOTE: Some of the methods you develop to detect adorability can be used for much more serious purposes. I first encountered this problem in the context of finding whether specific segments of DNA in a genome. uwu Part 3: Using your function from part 2, write a program that asks the user for a filename, opens that filename, and prints the following information about the file: How many strings are in the file How many of these strings are adorable The adorability proportion of the file. The most adorable string in the file. Adorability proportion consists of the total adorability count of all lines in the file, divided by the number of lines. Represent the adorability proportion as a floating-point number. Because lines can have an adorability count of more than 1, it is possible for the adorability proportion to be greater than 1. For example, a file containing the following lines: uwu wha???? uwuuu has an adorability proportion of 1.33. There are three lines, the first line has an adorability count of 1, the second line has an adorability count of O, and the third line has an adorability count of 3. Therefore, the total adorability count of the file is 4, the total number of lines in the file is 3, and so the adorability proportion is 4/3, or 1.333. Match the output format below exactly: There are [total count of strings in the file] lines in the file [filename] [count of adorable strings] of these lines are adorable. The adorability proportion of [filename] is [adorability proportion] The most adorable line is (text of the line with the highest adorability count]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions