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
Input is information a system uses to monitor and adjust itself to meet the goal.
agasfer [191]
That is a true statement. Hope this was helpful!
7 0
3 years ago
a customer is looking for efficient alert management for its Data centre operations for reducing human effort in monitoring and
MAXImum [283]

Answer:Yes !

Explanation:  I totally agree, he really is looking !

8 0
3 years ago
The icons to insert pictures and clip art in the PowerPoint application are located in the _____ grouping on the Insert tab.
saul85 [17]
The icons to insert pictures and clip art are located in the images grouping on the insert tab.
3 0
3 years ago
When using bits to represent fractions of a number, can you create all possible fractions? Why or why not?
kumpel [21]

Answer:

The essence including its issue is listed in the interpretation subsection below.

Explanation:

  • Representing means the practice of someone using abstract, tangible as well as pictorial symbols as well as phrases and related circumstances to discuss ideas and express comprehension.
  • Representing fractions could indeed be overcome in almost the same manner as the positive factors of twice represented integers are using the negative factors of two to summarize to essentially fractional amounts.
4 0
3 years ago
A storage location in the computer's memory that can hold a piece of data is called:
Zigmanuir [339]

Answer:

b. a variable

Explanation:

A variable holds a specific type of data

3 0
3 years ago
Other questions:
  • Does a soda vending machine Give reciepts?<br><br>need for computer science hw
    7·2 answers
  • Fair use allows individuals to break copyright so long as they ________.
    15·1 answer
  • Trisha is looking for a new table style. What is the fastest way for her to preview how different styles in the gallery would lo
    13·1 answer
  • So how do I repost a answer that I already answered to a question because I answered this question but later it told me to repos
    14·1 answer
  • If a firm is set to use open-source software with which no one in the IT department is familiar, what should it do? fire the IT
    14·2 answers
  • _____ provides vital protection and maintenance services for system hardware and software, including enterprise computing system
    12·1 answer
  • Write a C++ program that computes an approximation of pi (the mathematical constant used in many trigonometric and calculus appl
    15·1 answer
  • For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code.
    5·1 answer
  • Giusp minfg gấp vs ạ đáp án thôi nhé
    15·1 answer
  • What is the name of the directory that contains symbolic links to unix sysv rc scripts for runlevel 2?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!