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
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
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Help me
![Sample Testcase 0:
Input:
C++
F1.txt
1
Output:
3
Sample Testcase 1:
Input:
C++
F1.txt
Output:
Sample Testcase 2:
Input:
C++
F1.txt
2
Output:
Invalid
1.
#include <iostream>
2.
#include <fstream>
3 using namespace std;
4
5
int main()
{
char filename [20];// Use
this variable to read the name
8
of the file that contains the
text.
int mode;
string word;
cin>>word>>filename>> mode;
10
11
12
13 }
14](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3f1ee9e3-f3c8-4a83-b680-d31e737df19a%2F0c90301e-ec9f-4cc6-9a39-b38c6cfc4262%2F7ick4nd_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Sample Testcase 0:
Input:
C++
F1.txt
1
Output:
3
Sample Testcase 1:
Input:
C++
F1.txt
Output:
Sample Testcase 2:
Input:
C++
F1.txt
2
Output:
Invalid
1.
#include <iostream>
2.
#include <fstream>
3 using namespace std;
4
5
int main()
{
char filename [20];// Use
this variable to read the name
8
of the file that contains the
text.
int mode;
string word;
cin>>word>>filename>> mode;
10
11
12
13 }
14
![10:20 A 0 1.
O ll
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.
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3f1ee9e3-f3c8-4a83-b680-d31e737df19a%2F0c90301e-ec9f-4cc6-9a39-b38c6cfc4262%2Fd93mhct_processed.jpeg&w=3840&q=75)
Transcribed Image Text:10:20 A 0 1.
O ll
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.
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Hi
This code is not correct ?
I need
Solution
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY