In this lab you will be creating your own
personal reusable header file that contains at least two functions which will
be useful for validating input from the console.You will include this header in a program to
demonstrate how your functions work.
Header File
Your
header file MUST be named in
the following format:”LAB6_” followed by your last name and the last three
digits of your student number. For example: LAB6_MACDONALD123.
Your header file will include the following
functions:
IsValidDouble() – This function will return
true if the string passed to it could be converted to a double value and
returns false if not.
TryDoubleInput() – This function returns a
double value which it determines from input from an input stream (i.e. user
input from the console or input from a text file). Pass the input stream object
into the function as a parameter e.g. value = TryDoubleInput(cin); // example
function call.
Unlike versions of GetValidDouble () we have
worked on in previous labs and demos, TryDoubleInput() will not contain a loop
of be called recursively. Rather, if the input cannot be converted to a double
value, it will through a std::exception object. I would expect that you would
make use of your IsValidDouble() in this function.
Demo Program
Write a short program (e.g. separate .cpp file
with the main() function) which includes your header file and demonstrates
validating input using your TryDoubleInput() function. You do not have to
demonstrate IsValidInput() directly in your program and you should be making
use of try… catch.





