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
Which of the following for-loop headers results in equivalent numbers of iterations: A. for (int q = 1; q &lt;= 100; q++) B. for
vladimir2022 [97]

Answer:

b

Explanation:

C and D have equivalent iterations

C:       D:

99    990

90      900

81      810

72      720

63      630

54      540

45      450

36      360

27      270

18      180

9       90

8 0
3 years ago
For this exam review lab exercise, you will develop a program that fixes faulty data in a one-dimensional array of integers. Fau
Paladinen [302]

Answer:

start with what you know

Explanation:

3 0
3 years ago
What wired channel, commonly used for cable tv, consists of an insulated copper wire wrapped in a solid or braided shield placed
Airida [17]
the answer is A coaxial cable
8 0
3 years ago
Which of the following is a command shell with a built-in scripting language?1. The Server Manager’s Roles and Features wizard2.
IgorLugansk [536]
Your kinda right but wrong
4 0
3 years ago
Read 2 more answers
What's is flow chart?
TEA [102]

Answer: A flowchart is a graphical representation of decisions and their results mapped out in individual shapes.

Explanation:

These shapes were first developed by Herman Goldstine and John von Neumann in the 1940s.

Flowcharts can provide a step-by-step diagram for mapping out complex situations, such as programming code or troubleshooting problems with a computer.

4 0
3 years ago
Other questions:
  • 2- There are many different design parameters that are important to a cache’s overall performance. Below are listed parameters f
    11·1 answer
  • 5 What is the effect of the author proposing athought experiment at the beginning of the text? ​
    5·2 answers
  • Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
    8·2 answers
  • Computers are often referred to as _____.
    15·1 answer
  • Researching the history of computers is a good troubleshooting technique.<br> True or False?
    5·1 answer
  • To create a new folder, press ____.
    12·1 answer
  • Cameron oversees inventory tracking in her school store. Which feature in a database allows her to organize the items from highe
    6·1 answer
  • Tweaking existing technology in a new way is usually called _____. leveraged creativity state-of-the-art breakthrough applicatio
    5·1 answer
  • You designed a program to create a username using the first three letters from the first name and the first four letters of the
    6·1 answer
  • Why is a Quality assurance tester needed on a software development team?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!