Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. double TryDoubleInput()
  2. {
  3. double validDouble;
  4. string inputString;
  5.  
  6. //cin >> inputString; // accept a string input
  7. getline(cin, inputString);
  8. if (!isValidDouble(inputString))
  9. {
  10. cerr << "Invalid input. Please enter a whole number: ";
  11. validDouble = TryDoubleInput();
  12. }
  13. else
  14. {
  15. validDouble = atod(inputString.c_str()); // convert to an integer
  16. }
  17. return validDouble;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement