1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
matrenka [14]
2 years ago
13

1. Define a C++ function with the name evaluateBook. The function receives as one argument the name of the file to be processed

(i.e., the book's file). So that if you pass the English version, we will see the results only for that language.
2. Function evaluateBook opens the file, reads it, analyzes it, and prints the answer to the following questions:



a. What it the total number of text lines in the file?

b. What it the number of text lines without any lower-case letter? To answer this question, write and call the function testLowerCase.

c. What it the number of text lines without any number? To answer this question, write and call the function testNumber.

d. What is the total number of visible characters (so, excluding invisible codes such as '\n') ? To answer this question, write and call the function countCharacters.

e. What is the total number of letters (i.e., excluding symbols, numbers, etc.)? To answer this question, write and call the function countLetters.

f. How many times each of the following punctuation symbols appear: comma, period, double quotes, single quotes ?

g. What is the most popular letter (regardless of its case) ? (update: assume it is a vowel)

h. The word "et" in French means "and". How many times does this word appear? The function should search for both words, so that if you pass the English version, the count for "et" will be likely zero. Also, ignore the case, but do not count a matching if part of another word, such as "Andrew".
Computers and Technology
1 answer:
katovenus [111]2 years ago
4 0

Answer:

#include <iostream>

#include<string>

#include<fstream>

using namespace std;

void evaluateBook(string bookName);

int countCharacters(string bookLine);

int countLetters(string bookLine);

int totalPunctuations(string bookLine);

int main()

{

  evaluateBook("demo-book.txt");

  return 0;

}

int countCharacters(string bookLine) {

  return bookLine.length();

}

int countLetters(string bookLine) {

  int counter = 0;

  for (int i = 0; i < bookLine.length(); i++) {

      if ((bookLine[i] >= 'a' && bookLine[i] <= 'z') || (bookLine[i] >= 'A' && bookLine[i] <= 'Z')) {

          counter++;

      }

  }

  return counter;

}

int totalPunctuations(string bookLine) {

  int counter = 0;

  for (int i = 0; i < bookLine.length(); i++) {

      if (bookLine[i]=='\.' || bookLine[i]=='\,' || bookLine[i]=='\"' || bookLine[i]=='\'') {

          counter++;

      }

  }

  return counter;

}

void evaluateBook(string bookName) {

  ifstream in(bookName);

  int totalVisibleCharacters = 0,totalLetters=0,numberOfPunctuations=0;

  if (!in) {

      cout << "File not found!!\n";

      exit(0);

  }

  string bookLine;

  while (getline(in, bookLine)) {

      totalVisibleCharacters += countCharacters(bookLine);

      totalLetters += countLetters(bookLine);

      numberOfPunctuations += totalPunctuations(bookLine);

  }

  cout << "Total Visible charcters count: "<<totalVisibleCharacters << endl;

  cout << "Total letters count: " << totalLetters << endl;

  cout << "Total punctuations count: " << numberOfPunctuations<< endl;

}

Explanation:

  • Create a function that takes a bookLine string as a parameter and returns total number of visible character.
  • Create a function that takes a bookLine string as a parameter and returns total number of letters.
  • Create a function that takes a bookLine string as a parameter and returns total number of punctuation.
  • Inside the evaluateBook function, read the file line by line and track all the information by calling all the above created functions.
  • Lastly, display the results.

You might be interested in
Which situation is an example of? "relational context" in the transactional model of? communication?
Jlenok [28]
An example I believe of relational context is when I was out with my son on the weekend (he has a developmental disability) and we had agree I would buy him a 1/2 sub sandwich the day before but then he said I would like a McFlurry so I said okay and then he said so you mean I can have a McFlurry and a sub and I thought oh oh I stuck my foot in it so I said but it must be only a 1/2 sub so he said no I want a full sub then and no mcflurry so I agreed so from the original 1/2 sub idea the idea evolved to a full sub which was affected by the warm sunny summery weather in the afternoon and seeing people lined up at ice cream shops so the idea developed in relation to the weather, how hungry he was and the social aspect people buying ice cream.
8 0
2 years ago
Why would students most likely need to collect data? Check all that apply
n200080 [17]
Well I would think all of them in some way. For the first one, students need to collect data (whether it’s mathematical, scientific, etc.) to answer a question. For the second one, they may need to know how much money is in there bank account or they may need to calculate a sale to order the item. For the third one, they may need statistical data to support a position. For the last one, a student could use technological data to be able to solve their problem sorting documents.
5 0
3 years ago
Read 2 more answers
Risk of new technology is NOT evaluated by asking questions during which phase?
neonofarm [45]

Answer:

the answer is D

Explanation:

hope this helps :)

4 0
2 years ago
What linux command displays the ip address and subnet mask?
Nookie1986 [14]
Type "ifconfig" at the terminal prompt, then press the "Enter" key. The IP address is labeled as "inet addr." The subnet is labeled as "Mask."

step 2

Type "netstat -r" at the command prompt, then press the "Enter" key to view the gateway address.

3 0
3 years ago
Why does it help to differentiate among self-esteem,self-image, and self value
joja [24]

Evaluation of one’s own worth is termed as self-esteem. Each person will take the defeat and pointed out mistake in different manner. One person may shout if somebody points out mistake and another may handle it with smile. Self-esteem plays the role here.

Self image is an imaginary of picture of how an individual is in their own perspective and how the same person in the view of other person’s perspective. This is one of the important traits of the people.

Self-value: Setting a value of one self, analyzing various situations and facts and stamping the seal as either “good” or “bad” is called self-value.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a method so that the main() code below can be replaced by the simpler code that calls method mphandminutestomiles(). origi
    14·2 answers
  • Which protocol do e-mail programs use to identify the file types of attached files?
    7·1 answer
  • Which tag will you use if you want your web page to look the same as your source code?
    11·1 answer
  • jason works for a restaurant that serves only organic local produced what trend is this business following?
    6·2 answers
  • HELP PLZ !!
    13·1 answer
  • ______ is a type of computer software that is installed into devices such as printers, print servers, and various types of commu
    5·1 answer
  • When two or more tables share the same number of columns, and when their corresponding columns share the same or compatible doma
    12·1 answer
  • Write down the stages in the information prcessing cycle in correct order​
    5·1 answer
  • a farmer cultivates 1/4 of his farm with ground nuts and 2/5 of it with maize what is the total landnarea that is cultivated​
    12·1 answer
  • X = 10<br> y = 20<br> x &gt; y<br> print("if statement")<br> print("else statement")
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!