C++
PART B: (STRING) – 40%
Program Description:
Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file.
In addition, the program should read and display each word with the count of vowels in each word. For example :
The 1
Friend 2
Wrote 2
Write functions to process and display the results.
No non-constant global variables should be used.
Test your program using the file provided “paragraph.dat”.
CODE:
#include <iostream>
#include <fstream>
using namespace std;
//counting no. of vowels
int vowelsCount(string s){
int count=0;
//iterating each character of string
for(int i=0;i<s.length();i++){
//converting char to
lower case
s[i] =
tolower(s[i]);
//increment count if
char is vowel
if(s[i]=='a' ||
s[i]=='e' || s[i]=='i'|| s[i]=='o'|| s[i]=='u'){
count++;
}
}
//printing the count
return count;
}
int main()
{
//creating file object
ifstream inFile;
//opening file
inFile.open("paragraph.dat");
//if file not opened
if (!inFile) {
cout << "Unable to
open file";
exit(1); // terminate
with error
}
//reading word
string word;
cout<<"Enter word: ";
cin>>word;
string s;
//reading files contents
int count=0;
while (inFile >> s) {
if(s == word){
count++;
}
//printing words with
given no of vowels
cout<<s<<"
"<<vowelsCount(s)<<endl;
}
//printing word frequency
cout<<word<<" is present in
paragraph.dat "<<count<<" times";
//closing file
inFile.close();
return 0;
}
SCREENSHOT:


OUTPUT:

FILE

C++ PART B: (STRING) – 40% Program Description: Write a word search program that searches an...
Program Description: (C++). Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should count and display the number of characters in the input data file that are not vowels. Your program must do this by providing the following functions : void processFile(ifstream &inFile, string &word, int &wordCount, int &nonVowelCount) ; void...
C++ not C please Lyric Search Write a program that asks the user for a file name and a string to search for. The program should search the file for every occurrance of the string. When the string is found it should display the line that it iwas found on and report the total number of occurrances of the string at the end. Place a text file with your favorite song lyrics in it and use to to perform a...
Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming
‘C’ programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string X) Exit the program The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case...
Homework description::::: Write JAVA program with following description. Sample output with code will be helful... A compiler must examine tokens in a program and decide whether they are reserved words in the Java language, or identifiers defined by the user. Design a program that reads a Java program and makes a list of all the identifiers along with the number of occurrences of each identifier in the source code. To do this, you should make use of a dictionary. The...
Java Letter Counter: Write a program that asks the user to enter a string, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. Must use a do while loop and a counter!!!!
Exercise 3.1 (word count.py). Write a program that takes in a filename and string as input. Then print how many times that string appears inside the chosen file. If the file does not exist, continue asking for a filename until one is given that exists. Use your source code file as test input. Make sure to test files with that contain the same word multiple times. ? $ python3 word-count.py 2 Please enter a filename: wordcount.py 3 Please enter a...
C++ Write a program that uses an arrays of at least 20 string . It should call a function that uses the linear search algorithm to locate one of the name. Read list of name from an input file call "StudentName.txt" The function should keep a count of the numbers of comparisons it makes until it finds the value. The program then should call a function that uses the binary search algorithm to locate the same value. It should also...
Python Programming Write a program that counts how often a word occurs in a text file. Input: Ask the user for the name of an ASCII text file. Output: Display the numbers of top frequently appeared words and their frequencies. Pseudocode: 1) Read the file 2) Split the file into words 3) Count each word 4) Sort the words by frequencies, starting with the most frequent ones 5) Internally you should use some sort of data structure to keep track...
Write the following C++ program that searches for specified words hidden within a matrix of letters. 1) Read a file that the user specifies. The file will first specify the dimensions of the matrix (e.g., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix. 2) Following these two numbers, there will be a number of rows of letters. These letters should be read into your matrix row...