Question: The programming language is C++ Here is my current readDouble: double readDouble(string errorMsg, double min, double max) { double someDouble; //stores each double entered bool
The programming language is C++

Here is my current readDouble:
double readDouble(string errorMsg, double min, double max) { double someDouble; //stores each double entered bool valid = false; // loop control flag indicating validity of entry // initially assume not valid do { // read a double delimited by a whitespace character cin >> someDouble;
// valid if within min to max range; && is logical AND operator valid = someDouble >= min && someDouble
// if input has failed or is invalid or if next char is invalid clear // fail state and remove invalid input; || is logical OR operator if (cin.fail() || !valid || !isspace(cin.peek())) { cout
cin.clear(); //clear the fail state
// remove up to max number of chars in input stream or up to ' ' cin.ignore(numeric_limits
// when valid input received, remove from input stream up to 100 remaining // characters or until reaches the ' '
return someDouble; // return a valid double to calling enviroment }
Modify your readDouble function to add formatting for the min and max parameters such that very large and very small numbers (perhaps above 1e6 and below 1e-6) are displayed in scientific notation and other numbers and 0 are displayed in fixed decimal format. Use a precision of 6 for both formats. Code by using the ternary conditional operator?: and the logical operators && (and) II (or) in the error message cout statement
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
