Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double TryDoubleInput()
- {
- double validDouble;
- string inputString;
- //cin >> inputString; // accept a string input
- getline(cin, inputString);
- if (!isValidDouble(inputString))
- {
- cerr << "Invalid input. Please enter a whole number: ";
- validDouble = TryDoubleInput();
- }
- else
- {
- validDouble = atod(inputString.c_str()); // convert to an integer
- }
- return validDouble;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement