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:
Strings And Vectors
Exercise:
Programming Projects
Question:3 | ISBN:9780321531346 | Edition: 7

Question

Give the function definition for the function with the following function

declaration. Embed your definition in a suitable test program.

void get_double(double& input_number);

//Postcondition:input_number is given a value

//that the user approves of.

You can assume that the user types in the input in normal everyday

notation, such as 23.789, and does not use e-notation to type in the

number. Model your definition after the definition of the function get_int

given in Display 8.3 so that your function reads the input as characters,

edits the string of characters, and converts the resulting string to a number

of type double. You will need to define a function like read_and_clean that

is more sophisticated than the one in Display 8.2, since it must cope with

the decimal point. This is a fairly easy project. For a more difficult project,

allow the user to enter the number in either the normal everyday notation,

as discussed above, or in e-notation. Your function should decide whether

or not the input is in e-notation by reading the input, not by asking the user

whether she or he will use e-notation

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