SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
I/o Streams As An Introduction To Objects And Classes
Exercise:
Programming Projects
Question:13 | ISBN:9780321531346 | Edition: 7

Question

Write a program that allows the user to type in any one-line question and

then answers that question. The program will not really pay any attention

to the question, but will simply read the question line and discard all that

it reads. It always gives one of the following answers:

These answers are stored in a file (one answer per line), and your program simply reads the next answer from the file and writes it out as the answer to the question. After your program has read the entire file, it simply closes the file, reopens the file, and starts down the list of answers again.

Whenever your program outputs the first answer, it should replace the

two symbols #N with a number between 1 and 18 (including the

possibility of 1 and 18). In order to choose a number between 1 and 18,

your program should initialize a variable to 18 and decrease the variable’s

value by 1 each time it outputs a number so that the chapter numbers

count backward from 18 to 1. When the variable reaches the value 0, your

program should change its value back to 18. Give the number 17 the

name NUMBER_OF_CHAPTERS with a global named constant declaration

using the const modifier.

Hint: Use the function new_line defined in this chapter. I'm not sure, but I think you will find the answer in Chapter #N.

That's a good question.

If I were you, I would not worry about such things.

That question has puzzled philosophers for centuries.

I don't know. I'm just a machine.

Think about it and the answer will come to you.

I used to know the answer to that question, but I've forgotten it.

The answer can be found in a secret place in the woods.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.