Answer:
Explanation:
The solution code is written in Java.
Firstly, we create a Scanner object and prompt user to input a number (Line 5-6). Next, we create a try -catch block and place the parseDouble inside the try block. If the input is invalid (e.g. "abc"), a NumberFormatException error will be thrown and captured and set the num to 0 and display the error message (Line 11 - 13).