Question: this question has two parts, and the program should be written in C++. here's an explanation of what is an adorable string : Let's call
this question has two parts, and the program should be written in C++.
here's an explanation of what is an adorable string :
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".
function from part 0 (you will need this function for part 2):
int adorableCount(string word){
int count1=0;
for(int i=0;i for(int j=i+1;j for(int k=j+1;k if(tolower(word[i])=='u'&tolower(word[j])=='w'&&tolower(word[k])=='u'){ count1++;} }}} return count1; } 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: Using your function from part 0, 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 0, 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
Get step-by-step solutions from verified subject matter experts
