
(*********************************************************************

        Adapted from
        Roman E. Maeder: Programming in Mathematica,
        Second Edition, Addison-Wesley, 1991.

 *********************************************************************)


GetNumber[prompt_String, predicate_:(True&)] :=
	Module[{answer},
		While[ True,
			answer = Input[prompt];
			If[ NumberQ[answer] && predicate[answer], Break[] ];  (* good   *)
			If[ answer === EndOfFile, Break[] ];                  (* escape *)
			Print["Please enter a number that satisfies ", predicate]
		];
		answer
	]
