Advertisement
etonw

double input_double_range()

Jun 28th, 2022
928
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None
  1. double input_double_range()
  2. {
  3.     bool valid_input = false;
  4.     double n;
  5.  
  6.     do
  7.     {
  8.         std::cout << " (enter number between 0 and 24): ";
  9.         std::cin >> n;
  10.         if (0 <=n && n <=24 )
  11.         {
  12.             valid_input = true;
  13.         }
  14.         else // Error statement
  15.         {
  16.             valid_input = false;
  17.             cout << "You have not entered a valid input" << endl
  18.                  << endl;
  19.         }    
  20.     } while(valid_input == false);
  21.     return n;
  22. }
Advertisement
RAW Paste Data Copied
Advertisement