Computers and Technology
19.06.2022 12:02
279
365
6
Solved by an expert

1. Define a C++ function with the name evaluateBook. The function receives as one

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".
Show Answers
sky724
sky724
5,0(95 marks)

#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.
leem6
leem6
4,6(23 marks)

False

Okay now I have to go to my school--

Popular Questions about the subject: Computers and Technology

Please add me on discord I m lonely lol. ℙ ()#0210...
Computers and Technology
19.12.2020 19:21
5. The two basic components that make up a computer system are a Hardware...
Computers and Technology
06.02.2020 04:47
Write a program to calculate the volume of a cube which contains 27 number...
Computers and Technology
21.05.2021 05:36
divide the input array into thirds (rather than halves), recursively sort...
Computers and Technology
16.12.2020 11:10
a swapping system in which memory consists of the following holes sizes...
Computers and Technology
07.08.2020 02:11
Consider the following modification to the Merge Sort algorithm: divide...
Computers and Technology
06.07.2021 10:29
1. Suppose that algorithm A takes 1000n3 steps and algorithm B takes 2n...
Computers and Technology
08.12.2022 07:10
Testing your System Call To test your system call, write a simple program...
Computers and Technology
26.01.2023 20:17
Write a C function int rectArea (int len, int wid) that returns the area...
Computers and Technology
01.03.2020 06:34
write a program with total change amount as an integer input and output...
Computers and Technology
31.10.2020 07:51

New questions by subject

Using the demand curve, how many goods would be demanded at $450?​...
Business
04.05.2021 19:47
PLEASE HELP Here is an equation. P = d(4 + tg) What is the equation when...
Mathematics
16.05.2023 15:08
WILL BE MARKED AS BRAINLIEST HELP!!! SOMEONE PLEASE CHECK OR MAKE CORRECTIONS...
Mathematics
01.10.2021 13:55
CAN SOMEONE GIVE ME A HELPING HAND WITH THIS PLEASE? THANK YOU FOR YOUR...
Mathematics
10.04.2023 06:08
Help me with this please...
Biology
05.12.2022 02:39
Yes plz help w homework xp​...
Mathematics
19.02.2022 03:52
#
#
#
#
# #

We expand our knowledge with many expert answers