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]
3 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]3 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
Obtain the 10’s complement of the following six-digit decimal numbers:<br><br> 123900<br><br> 980657
zysi [14]

Answer:

876100

019343

Explanation:

10s complement of a decimal number is obtained by the following process:

- Obtain 9s complement ( Subtract each digit by 9)

- Add 1 to the result

1) 123900

9s complement => (9-1)(9-2)(9-3)(9-9)(9-0)(9-0)

= 876099

Adding 1 , 10s complement of 123900 = 876100

2) 980657

9s complement = (9-9)(9-8)(9-0)(9-6)(9-5)(9-7)

= 019342

Adding 1 , 10s complement of 980657 = 019343

7 0
3 years ago
How do networks help protect data? -by preventing access by more than one person at a time -by restricting access to department
Whitepunk [10]

Answer:

because they have to rest

3 0
2 years ago
Read 2 more answers
Who is the father of modern computer?​
nydimaria [60]

Answer:

I would say Alan Turing is the father of the modern computer

7 0
3 years ago
Read 2 more answers
If u reading this ,DO THAT WORK
Ivenika [448]
I am.


Explanation


Characters
7 0
2 years ago
After a system is released and the user base grows, the demands on the development and support team will ______.
otez555 [7]

After a system is released and the user base grows, the demands on the development and support team will increase.

The development team can scale vertically by adding new people to the team.

6 0
3 years ago
Other questions:
  • Need help with this please and thanks
    7·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    10·1 answer
  • Using social media and sending a blast are examples of
    13·1 answer
  • • The length of time between water level measurements/ control adjustments is DT. • If the water level drops to the bottom of th
    13·1 answer
  • Suppose that a is a one-dimensional array of ints with a length of at least 2. Which of the following code fragments successfull
    8·1 answer
  • Copy the countdown function from Section 5.8 of your textbook. def countdown(n): if n &lt;= 0: print('Blastoff!') else: print(n)
    8·1 answer
  • Write at least complete set of HTML code to hyperlink to “Home.html”..
    8·1 answer
  • A corporate or government network that uses Internet tools, such as Web browsers, and
    13·1 answer
  • Your agile team only has one database developer. So the other developers finish their tasks and then wait for their work to be I
    6·1 answer
  • During which phase of system development would you acquire any necessary hardware and software?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!