2:56 D Write a program that finds the number of times a specific word appears in a text file. The program should accept the following inputs from the user: • The word that you are looking for. The word length should be 3 or more otherwise the program should print Too short. The word should not have a space character. • The name of the file that contains the text • The type of the search o O for case senstive search o 1 for case insensitive search o For any other input the program should output Invalid o Note that the word should be preceded and succeeded by spaces. Note: Assume for all sample test cases that thecontent of F1.txt is: C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide c++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms. I/0 Program Input: • A single line that takes in the word that you are searching for • A single line that takes in the name of the file that contains the text • A single line that takes in the type of the search Program Output: • A single line that outputs either the number of occurences of the word in the textfile.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.5: A Case Study: Pollen Count File Update
Problem 3E
icon
Related questions
Question
C++
Sample Testcase 0:
Input:
C++
F1.txt
1
Output:
3
Sample Testcase 1:
Input:
C++
F1.txt
Output:
1
Sample Testcase 2:
Input:
C++
F1.txt
2
Output:
Invalid
1.
#include <iostream>
2 #include <fstream>
using namespace std;
int main()
{
char filename [20];// Use
this variable to read the name
7
8
of the file that contains the
text.
9
int mode;
string word;
cin>>word>>filename>>mode;
10
11
12
13 }
14
Transcribed Image Text:Sample Testcase 0: Input: C++ F1.txt 1 Output: 3 Sample Testcase 1: Input: C++ F1.txt Output: 1 Sample Testcase 2: Input: C++ F1.txt 2 Output: Invalid 1. #include <iostream> 2 #include <fstream> using namespace std; int main() { char filename [20];// Use this variable to read the name 7 8 of the file that contains the text. 9 int mode; string word; cin>>word>>filename>>mode; 10 11 12 13 } 14
2:56 A
Write a program that finds the number of times a
specific word appears in a text file. The program
should accept the following inputs from the user:
• The word that you are looking for. The word
length should be 3 or more otherwise the
program should print Too short. The word
should not have a space character.
• The name of the file that contains the text
• The type of the search
O for case senstive search
o 1 for case insensitive search
o For any other input the program
should output Invalid
o Note that the word should be
preceded and succeeded by spaces.
Note: Assume for all sample test cases that
thecontent of F1.txt is:
C++ is a general-purpose programming language
created by Bjarne Stroustrup as an extension of
the C programming language, or "C with Classes".
The language has expanded significantly over
time, and modern C++ now has object-oriented,
generic, and functional features in addition to
facilities for low-level memory manipulation. It is
almost always implemented as a compiled
language, and many vendors provide c++
compilers, including the Free Software
Foundation, LLVM, Microsoft, Intel, Oracle, and
IBM, so it is available on many platforms.
1/0
Program Input:
• A single line that takes in the word that
you are searching for
• A single line that takes in the name of
the file that contains the text
• A single line that takes in the type of
the search
Program Output:
• A single line that outputs either the
number of occurences of the word in
the textfile.
Transcribed Image Text:2:56 A Write a program that finds the number of times a specific word appears in a text file. The program should accept the following inputs from the user: • The word that you are looking for. The word length should be 3 or more otherwise the program should print Too short. The word should not have a space character. • The name of the file that contains the text • The type of the search O for case senstive search o 1 for case insensitive search o For any other input the program should output Invalid o Note that the word should be preceded and succeeded by spaces. Note: Assume for all sample test cases that thecontent of F1.txt is: C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significantly over time, and modern C++ now has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation. It is almost always implemented as a compiled language, and many vendors provide c++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms. 1/0 Program Input: • A single line that takes in the word that you are searching for • A single line that takes in the name of the file that contains the text • A single line that takes in the type of the search Program Output: • A single line that outputs either the number of occurences of the word in the textfile.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr