Question: I am writing a program where the application has text fields to enter dollar amounts. 

There are methods that need to throw exceptions for items such as dollar amounts less than zero. when doing this I have check for exceptions like this:

```
if (Double.parseDouble(str) <= 0 || Double.parseDouble(str) > 10000)
    throw new InvaildDepositAmount("Deposit Amount " + str);
else
    totalBalance += amount;

```

My question is : Do I need to use the `Double.parseDouble(str)` every time I want to use this input, such in the `InvalidDepositAmount` class?

Answer: 
The simple answer is **no**. You can parse it once and use it as a variable later.

```
double depositAmount = Double.parseDouble(str);
if (depositAmount <= 0 || depositAmount > 10000)
    throw new InvaildDepositAmount("Deposit Amount " + depositAmount);
else
    totalBalance += depositAmount;

```

This is also more efficient because, what if the call to `parseDouble` were expensive (that is, it took a long time for it to get an answer)? Calling it once would be more efficient and easier to read in the long run.
Looks like you have following cases here:  

1. input field that should accept only double numbers  

2. some functions which accept limited range of double numbers

Obviously you can cache entered value to avoid redundant invocation of Double.parseDouble. Also you should keep that cached value actual and update it if user changed the value in input field.

In case of exceptions related to limits in your functions you can show some popup, or update status line or whatever is suitable for your application. Or probably you want to limit input field about entered value and validate value after each change.