Computers and Technology
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);
}
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:00, sere50
Stacy works as blank. the most important soft skill she needs for this role is blank.
Answers: 3
image
Computers and Technology, 23.06.2019 01:50, akornegay2
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, woodpeckerdeejpe8wvh
How to launch an app: steps to be successful? launching an app is a great idea, but it’s not that easy as we supposed to think. the majority of mobile applications don’t generate revenue because companies aren’t ready to be competitive. referring to our experience in successfully building and launching apps we hope to you omit these difficulties. we are going to talk about ideas, marketing, testing your product, its development, distribution and support. you will learn 8 product launch stages to succeed.
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, Princessirisperez0
Given a link with a maximum transmission rate of 32.8 mbps. only two computers, x and y, wish to transmit starting at time t = 0 seconds. computer x sends filex (4 mib) and computer y sends filey (244 kib), both starting at time t = 0. statistical multiplexing is used, with details as follows packet payload size = 1000 bytes packet header size = 24 bytes (overhead) ignore processing and queueing delays assume partial packets (packets consisting of less than 1000 bytes of data) are padded so that they are the same size as full packets. assume continuous alternating-packet transmission. computer x gets the transmission medium first. at what time (t = ? ) would filey finish transmitting? give answer in milliseconds, without units, and round to one decimal places (e. g. for an answer of 0.013777 seconds you would enter "13.8" without the quotes)
Answers: 3
Do you know the correct answer?
For this assignment, you will create a program that reads and prints a joke and its punch line from...

Questions in other subjects: