# calculation

• 07-01-2012, 04:04 PM
Powersolo
calculation
Hello,

I don't know very much about actionscript. Just enough to get by. I'm trying to put together a small application. I want the user to enter information, weight, and the application to tell the user which product to order. If the weight is within 1 of 4 ranges, he will use product #1, 2, 3, or 4. How can I get the product number to be entered in a seperate box if the weight falls within a certain range? I've figured out how to make calculations, but not conditions. Any help would be appreciated.
thanks,

Powersolo
• 07-10-2012, 05:12 PM
Nialsh
Code:

```var x = /* user input */ if (x < 10) {   // bottom unbounded range x < 10 } else if (x < 15) {   // 10 <= x < 15 } else if (x < 20) {   // 15 <= x < 20 } else {   // top unbounded range x >= 20 }```
If you want to test for the second range by itself, do so like this:
Code:

```if (x >= 10 && x < 15) {   // 10 <= x < 15 }```
If you want to test for the second OR 4th range, do so like this:
Code:

```if ((x >= 10 && x < 15) || x >= 20) {   // 10 <= x < 15 or x >= 20 }```
&& is "and". || is "or". They are called short-circuit logic operators.