Concept explainers
File Filter
A file filter reads an input file, transforms it in some way, and writes the results to an output file. Write an abstract file filter class that defines a pure virtual function for transforming a character. Create one subclass of your file filter class that performs encryption, another that transforms a file to all uppercase, and another that creates an unchanged copy of the original file.
The class should have a member function
void doFilter(ifstream &in, ofstream &out)
that is called to perform the actual filtering. The member function for transforming a single character should have the prototype
char transform(char ch)
The encryption class should have a constructor that takes an integer as an argument and uses it as the encryption key.
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
STARTING OUT WITH C++ MPL
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Concepts Of Programming Languages
Problem Solving with C++ (10th Edition)
Digital Fundamentals (11th Edition)
Database Concepts (7th Edition)
- PROGRAMMING LANGUAGE: C++ Implement another class with name UniversityClass which is composed of one teacher and multiple students(use student array) as data members. Another data member of UniversityClass is CourseName that is just a string data member. Write a function in UniversityClass to take Teacher Name, Student names and course name from user. Insert these records in a text file and print screenshot of that text file. Print UniversityClass code here. Print main function here. Print screenshot of text file here.arrow_forwardSample run: Your 1st vector contains the following elements January February March April May June July August September October November December Your 2nd vector contains the following elements May June Julyarrow_forwardProgram language: C++ A publishing company markets both hardcopy and eBook versions of its work. Create a class publication that stores the title and price of a publication. From this class derive two classes: book, which adds a page count, and digital, which adds a storage capacity in MG bytes. Each of these classes should have a getdata() function to get its data from the user at the keyboard and put a putdata() function to display its data. Add a base class sales that hold an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getData() function to get three sales amounts from the user and a putdata() function to display the sales figures. Modify the book and digital classes so they are derived from both publication and sales. An object of the class book or digital should input and output sales data along with its other data. Write the main function to create a book object and a digital object and test their…arrow_forward
- Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: 1. A default constructor which sets all the numeric instance variables to zero. 2. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. 3. Implement a getter function for each of the 4 instance variables that will return the value of the instance variable. For example, the getX() function for the instance variable model must be called getModel(). 4. Implement a setter function for each instance variable that will assign to the instance variable to the value passed. For example, the setX() function for the instance variable model must be called setModel(). 5. An info function: this function…arrow_forwardC++arrow_forwardC++ Write a code segment that creates an ofstream object named outfile, opens a file named numfile.txt, and associates it with outfile. Then write the contents of the variable data to the file, followed by a newline, then close the file.arrow_forward
- First programming homework Create a class of records for a gradebook called Rec. The data should be private, and should include a firstname, lastname, array of three grades, and a field for average grade. Build two constructors: a default constructor and a constructor that takes the first and last name. Build a function to read the data, either from a file or from cin. The read function reads the two names and three grades, but does not read the average grade. Build a write function that writes the data either to a file or to cout. The write function prints all of the data on one line with spaces between fields. Build a function to calculate the average grade field. Build an overloaded operator == to compare two records. This should be implemented as a friend function. Declare the constructors and functions in the body of the class, but implement them outside the class. I will provide you with a driver called hw1.cpp in ~cthorpe/public/142 and with a test file HW1.txt in the same…arrow_forwardC++ I cannot run the code. Please help me fix it. Below is the requirement of the code. Design and write a C++ class that reads text, binary and csv files. The class functions: Size: Returns the file sizeName: Returns the file nameRaw: Returns the unparsed raw data (use vector here to get the unparsed raw data)Parse: A external function to Parse the data. The function accepts the raw data and returns the data parsed by the function. This type of function is called a "Call-Back Function". A Call-Back is necessary for each file as each file requires different regular expressions to parse. With binary files, need to use RegEx to do the parse(). [My code doesn't have this part] Please refer to the Callback.cpp example on how to setup a Call-Back. CallBack.cpp: #include <string>#include <functional>#include <iostream>#include <vector>using namespace std; string ToLower(string s){ string temp; for (char c : s)…arrow_forwardFile Stream Problem: Implement a Caesar cipher that can encrypt and decrypt text and file. A Caesar cipher is a substitution cipher that shifts the letters in the original message x spaces ascending the alphabet where x is the key. Example if the key for the cipher is 3, and the message is “I will be there.” Then the coded message would be “L zloo eh wkhuh” Program requirements: Create a class call CCipher that has two member functions encrypt and decrypt. The program should be able to encrypt/decrypt a message from a file as well as a keyboard input. The default key should be 3. The user should be able to select between encrypting and decrypting and should be allowed to do so multiple times until s/he decides to end the program. The file format to be encrypted should be a “.txt” and the user should be able to provide the name of the file to be encrypted, after which the file should be deleted. The user should have the option to view…arrow_forward
- JAVA PPROGRAM Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find matches you should print the name and the line numbers where the match was found. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name. The file may contain up to 100 names. You can use an array or ArrayList object of your choosing, however you can only have one array or ArrayList. Input validation: a) If the file does not exist, then you should display a message "File 'somefile.txt' is not found." and allow the…arrow_forwardTRUE FALSE The dereference operator * is used to obtain the address of a variable. The void functions return noting when called. the flag eof() is FALSE at the beginning of a text file. There is no way to show text on graphic screen The reserved word struct is used when declaring a void function.arrow_forwardThe struct song is defined as : typedef struct { char* title; char* artist; int year; } song; Write the following two functions maintaining a database of entries of type song in a file in c language . (int add_song(const char* file_name, const song s);The function gets the name of a file, and a song. If the song is not in the file, the function adds it to the file and returns 1. Otherwise, the function does not modify the file and returns 0. song* find_song(const char* file_name, const char* title); The function gets the name of a file and a title of a song. It searches the file for the song with the given title. If a song is found, it returns a pointer to the song with all the details. If not found, the function returns NULL. You may assume the song titles are unique.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,