Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Punch Line I need to write a C++ program using DEV C++ that reads and prints a j

ID: 3633639 • Letter: P

Question


Punch Line
I need to write a C++ program using DEV C++ 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 “ garabage.” The main function of the program should open the 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 the beginning of the last line. Data to test program can be found in the joke.txt and punchline.txt files.


+++++++++++++++++ joke.txt++++++++++++++++++++++++++++++++++++++=
Two men who work together in a facory were talking.
"I know how to get some time off," said one.
"How are you going to do that?" asked the other.
"Watch," he said, and climbed a ladder to the ceiling.
The foreman asked what he was doing up there,
and the man replied. "I'm a lightbulb."
"I think you need some time off," the foreman
said, and the first man walked out of the
factory. After a moment, the second man followed
him. "Where do you think you're going?"
the foreman shouted.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*********************************************punchline.txt***************************************
asfasdfasdfasdfsdf
asdfasdfsadfsadfsadf
asdfsadfsdfsdf
"I can't work in the dark," he said.

********************************************************************************************************

Explanation / Answer

Dear, // HA-CPP-FileRead.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include //needed for file operations #include //needed for I/O operations #include using namespace std; void fileJoke(string); void filePline(string); void main() { fileJoke("joke.txt"); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote