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 ,kenrick Mock
Chapter:
Streams And File Io
Exercise:
Programming Projects
Question:13 | ISBN:9780132846813 | Edition: 5

Question

This project is the same as Programming Project 13.12 except that in this project your program will use a more sophisticated method for choosing the answer to a question. When your program reads a question, it counts the number of characters in the question and stores the number in a variable named count. It then responds with answer number count%ANSWERS . The first answer in the file is answer number 0, the next is answer number 1, then 2, and so forth. ANSWERS is defined in a constant declaration, as shown next, so that it is equal to the number of answers in the answer file:

const int ANSWERS = 8;

This way you can change the answer file so that it contains more or fewer answers and you need to change only the constant declaration to make your program work correctly for a different number of possible answers. Assume that the answer listed first in the file will always be the following, even if the answer file is changed:

I'm not sure but I think you will find the answer in Chapter #N.

When replacing the two characters #N with a number, use the number (count NUMBER_OF_CHAPTERS + 1), where count is the variable discussed previously, and NUMBER_OF_CHAPTERS is a global named constant defined to be equal to the number of chapters in this book.


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'.