`# APIs for user input import std/strutils # For parse # Function to get user input and convert to float proc getFloatInput(prompt: string): float = var user_input: float while true: try: echo prompt user_input = readLine(stdin).parseFloat() break except ValueError: echo "Invalid input. Please enter a valid number." except IOError: echo "An I/O error occurred." except Exception as e: echo "An unexpected error occurred: ", e.msg user_input # Function to get user input and convert to int proc getIntInput(prompt: string): int = var user_input: int while true: try: echo prompt user_input = readLine(stdin).parseInt() break except ValueError: echo "Invalid input. Please enter a valid number." except IOError: echo "An I/O error occurred." except Exception as e: echo "An unexpected error occurred: ", e.msg user_input # Function to get user input: text proc getTextInput(prompt: string): string = var user_input: string while true: try: echo prompt user_input = readLine(stdin) break except ValueError: echo "Invalid input. Please enter a valid number." except IOError: echo "An I/O error occurred." except Exception as e: echo "An unexpected error occurred: ", e.msg user_input`