+ let getKeyBoardInput () =
+ System.Console.ReadLine()
+let rec promptUser (inputMethod:unit->string) (message:string) (matchingExpression:string->string option) =
+ let formattedMessage = Printf.TextWriterFormat<unit>(message)
+ printfn formattedMessage
+ let input = inputMethod()
+ let result = matchingExpression input
+ | None -> promptUser inputMethod message matchingExpression
+let sentenceMatchingExpression (input:string) =
+ if input.StartsWith "A" then Some input
+let prompt = "Please enter a string that starts with A."
+let result = promptUser getKeyboardInput prompt sentenceMatchingExpression
+printfn "You entered %s" result
+let validNumberOfHoursToWork (input:string) =
+ match System.Int32.TryParse(input) with
+ | (true,int) -> if int <= 40 && int >= 1 then Some input
+let numHoursWorkedPrompt = "Please enter then number of hours worked."
+let numHoursWorked = (promptUser getKeyBoardInput numHoursWorkedPrompt validNumberOfHoursToWork) |> Int32.Parse
+printfn "You worked %i" numHoursWorked