The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
3. Punch Line
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 A????1garbage.A????1 The main function of your 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 your program can be found in the joke.dat and punchline.dat files.
joke.dat :
Q: What did the tongue say to the teeth?
 Â
punchline.dat
This is not the punch line.
This is not the punch line.
This is not the punch line.
This is not the punch line.
This is not the punch line.
This is not the punch line.
A: If you bite me again, I will give you a licking.
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------