What does the following code do?
```
1 try
2 {
3 double myDouble1 =
4 Double.parseDouble( double1JTextField.getText() );
5 double myDouble2 =
6 Double.parseDouble( double2JTextField.getText() );
7 double result = myDouble1 * myDouble2;
8 resultJTextField.setText( String.valueOf( result ) );
9 }
10 catch( NumberFormatException exception )
11 {
12 JOptionPane.showMessageDialog( this,
13 "Please enter decimal numbers",
14 "NumberFormatException occurs", JOptionPane.ERROR_MESSAGE );
15 }
/code}
This code multiplies two doubles if both inputs in double1JTextField and double2JTextField are indeed decimal numbers, including integers. Otherwise it displays an error message dialog that informs the user to enter decimal numbers in the JTextFields.
You might also like to view...
Discuss controlling an object's speed in an animation.
What will be an ideal response?
Many states have court records online
Indicate whether the statement is true or false.
What is the Distributed File System service available through the File and Storage Services role?
What will be an ideal response?
What challenges are being posed by the Internet of Things (IoT)??
What will be an ideal response?