subject
Computers and Technology, 29.07.2020 01:01 indya2

For this assignment, you will create 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." You can pick the joke and the punchline, but please make sure the joke is not inappropriate or offensive in nature. 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. You must create all files for this program. Be sure to include comments throughout your code where appropriate. Make sure that your comments thoroughly explain the stream input/output and what is happening in your program. 1 //Charles Blackwell CIS 221 M4
2 #include
3 #include
4 #include
5
6 using namespace std;
7
8 void printfirstfile(ifstream &);
9void printsecondfile(ifstream &);
10
11 int main() {
12 ifstream joke;
13 ifstream punchline;
14
15// print the joke
16 joke. open("joke. txt", ios::in);
17 if (!joke) {
18 cout << "Error opening the joke. " << endl;
19 return 0;
20 }
21 cout << " Charles Joke " << endl;
22 cout << "" << endl;
23 printfirstfile(joke);
24
25 punchline. open("punchline. txt", ios::in);
26 if (!punchline) {
27 cout << "Error opening the punchline. " << endl;
28 return 0;
29 }
30 cout << " Charles punchline " << endl;
31 cout << "" << endl;
32 printsecondfile(punchline);
33 return 0;
34
35 }
36 void printfirstfile(ifstream& file) {
37
38
39 char ch;
40 file. get(ch);
41
42 while (file) {
cout << ch;
file. get(ch);
}
}
void printsecondfile(ifstream& file) {
char ch;
file. seekg(-1L, ios::end);
file. get(ch);
while (ch != '\n') {
file. seekg(-2L, ios::cur);
file. get(ch);
}
file. get(ch);
while (!file. eof()) {
cout << ch;
file. get(ch);
}
}

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, itsyagirl11076
What is the process in which the software development team compiles information to determine the final product.
Answers: 3
image
Computers and Technology, 22.06.2019 07:20, Hcalhoun21
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
image
Computers and Technology, 22.06.2019 17:50, ImBADatmath8743
Farah works in an office with two other employees. all three share a printer and an internet connection. the utility that makes this possible is defragger quicktime soho winzip
Answers: 1
image
Computers and Technology, 24.06.2019 15:20, 710jonathan
Local area networks use many of the same network technologies and the internet, only on a smaller scale. devices that access lans are equipped with a network interface that contains circuitry for wireless or wired connections. devices also have a physical address, in addition to the ip addresses acquired from a dhcp server. the most popular wired technology is . the most popular wireless technology is , which can be configured as a(n) or star topology. setting up a lan and configuring its router is fairly easy. the first step is to change the standard to one that is secure. next, create a(n) that uniquely identifies the network by name. it is also important to activate wireless to prevent wireless signals from being intercepted during transmission. a limited-access network can be created for visitors to use. by activating , the router will be able to assign ip addresses to each device that joins the network. to connect to a secure lan that is protected by encryption, an encryption , or password, is required. lans can be used to access data collected by iot devices and the networks that tie these devices together. technologies such as rfid, nfc, bluetooth smart, zigbee, and z-wave offer -power links, essential for battery-powered devices that can’t expend excess amounts of energy transmitting data.
Answers: 1
You know the right answer?
For this assignment, you will create a program that reads and prints a joke and its punch line from...

Questions in other subjects:

Konu
Mathematics, 19.10.2019 04:10
Konu
History, 19.10.2019 04:10