Punch Line C++ Program Write a program that reads and prints a joke and its punc
ID: 3633550 • Letter: P
Question
Punch Line C++ Program
Write a program that reads and prints a joke and its punch line from two different files. The first file contains a joke, but not its punch line. The second file has the punch line as its last line, preceded by "garbage." The main function of your program should open two files and then call two functions, passing each one the file it needs. The first function should read and display each line in the file it is passed (the joke file). The second function should display only the last line of the file it is passed ( the punch line file). It should find this line by seeking to the end of the file and then backing up to beginning of the last line. Also the data to test the program can be found in the joke.txt and pucnhline.txt files.
Explanation / Answer
#include #include #include using namespace std; // Function prototypes void displayJoke(ifstream &inputFile); void displayPunchline(ifstream &inputFile); int main() { string file1, //First File file2; //Second File ifstream joke, //Input File Joke punchline; //Input File Punchline coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.