Implement the void writeToFile( vector<TokenFreq> &tokFreqV, string outFileName); function. This function receives a vector of TokenFreq objects and writes each token and its frequency on a separate line in the specified output file.
void writeToFile(vector<TokenFreq> &tokFreqV, string
outFileName){
ofstream outFile(outFileName.c_str());
for(int i = 0; i < tokFreqV.size(); i++){
outFile << tokFreqV[i].value << " - " <<
tokFreqV[i].freq << "\n";
}
outFile.close();
}
Implement the void writeToFile( vector<TokenFreq> &tokFreqV, string outFileName); function. This function receives a vector of TokenFreq...
(3) Problem P6.10. Implement a function void remove.duplicates (vector<int> & v) discussed in Problem 6.10 that removes duplicates from a vector. Write a program that prompts the user to enter a list of integers and then use the above function to remove duplicates. Then display the modified vector. Implement a loop in which the above actions are repeated until the user requests to quit. . Assume that the lists of integers is nonempty Assume that the the user's input is...
Write a function named mostFrequent that takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file inFile exists when mostFrequent is called; mostFrequent must create outFile. The input file contains only lower case letters and white space. The function mostFrequent identifies the letter(s) that appear most frequently on each line of inFile and writes them to a corresponding line of...
Q1.A. Write a function toCapital() in ‘C’ to RETURN A STRING IN CAPITALS Prototype : void toCapital(char *); B. Use the above function to convert a file into capitals. File names should be passed at the command line.
Please use C++ to code
Exercise P10.11. Implement a function vector<string> generate_subsets (string s) that generates all subsets of characters of a string. For example, the subsets of char acters of the string "rum" are the eight strings rum", "ru" Note that the subsets don't have to be substrings-for example, "rm" isn't a sub- string of rum , "rm" ,um
Given the Following Fucntions, Give the Space and
time analysis for each function
void DELETE(vector < char > myArray[90], string myLine)//deletes the specified member from the set { //compares the specified member to each member in the set for (int i = 0: i < myArray[myLine[9]].size(): i++)//if the member is found it is erased { if (myLine[7] == myArray[myLine[9]][i]) { myArray[myLine[9]].erase(myArray[myLine[9]].begin() + (i)): } } void PRINTSET(vector < char > myArray[90], string myLine, ofstream &outs)//prints the members of the specified...
D.1 [3] Define a function called funD1...) that receives a string and returns a new string with all the characters in the original string in an EVEN position. As an example, the following code fragment: print (funD1('abcde')) should produce the output: ace D.2 [6] Define a function funD2(...) which receives a list ist that contains single letters, single digits and single special characters and the list contains at least one element of each type). The function returns a string that...
c# csci312: character counter - vector design a program that reads in an ascii text file (provided) ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provide... C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provided) and creates an output file that contains each unique ASCII...
JAVA QUESTION - BalancedParentheses Implement the class BalancedParentheses with a method isBalanced that receives a String and checks whether the brackets in it are balanced. import java.util.Scanner; public class BalancedParentheses { public static void main(String[] args) { checkParentheses("((a + b) * t/2 * (1 - t)"); checkParentheses("(a + b) * t)/(2 * (1 - t)"); checkParentheses("a + ((a + b) * t)/(2 * (1 - t))"); System.out.println("Enter an expression: "); Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); checkParentheses(s);...
If i could get any guidance on how to get this started it will be great. My prof. literally just gave us the information below (which are literally just instructions) and I am unsure on how to get started. For this assignment we are going to create a function that reads an input stream and classifies it into “tokens” from a language that we define here. In this language we make the following rules: ● An identifier is a letter...
I keep getting errors and i am so confused can someone please help and show the input and output ive tried so many times cant seem to get it.
main.cpp
#include <iostream>
#include <vector>
#include <string>
#include "functions.h"
int main()
{
char option;
vector<movie> movies;
while (true)
{
printMenu();
cin >>
option;
cin.ignore();
switch (option)
{
case 'A':
{
string nm;
int year;
string genre;
cout << "Movie Name: ";
getline(cin, nm);
cout << "Year: ";
cin >> year;
cout << "Genre: ";
cin >> genre;
//call you addMovie() here
addMovie(nm, year, genre, &movies);
cout << "Added " << nm << " to the catalog"
<< endl;
break;
}
case 'R':
{
string mn;
cout << "Movie Name:";
getline(cin, mn);
bool found;
//call you removeMovie() here
found = removeMovie(mn, &movies);
if (found == false)
cout << "Cannot find " << mn << endl;
else
cout << "Removed " << mn << " from catalog"
<< endl;
break;
}
case 'O':
{
string mn;
cout << "Movie Name: ";
getline(cin, mn);
cout << endl;
//call you movieInfo function here
movieInfo(mn, movies);
break;
}
case 'C':
{
cout << "There are " << movies.size() << " movies
in the catalog" << endl;
// Call the printCatalog function here
printCatalog(movies);
break;
}
case 'F':
{
string inputFile;
bool isOpen;
cin >> inputFile;
cout << "Reading catalog info from " << inputFile
<< endl;
//call you readFromFile() in here
isOpen = readFile(inputFile, &movies);
if (isOpen == false)
cout << "File not found" << endl;...