If statements, Multiple Conditions, && and ||
-
Hi I am trying to create a calculation amount based on the following answers on the form:
-their annual income (fieldname 2)
-their monetary assets (fieldname 3)
-number of people in their household (fieldname16)
-status (Single or Married) (Fieldname15)
-Financing Plan (Yes or No) (fieldname20)This is what I got so far, any suggestions, corrections, or help would be greatly appreciated!
a)
Condition:If one person household (fieldname16), with NO finance plan (fieldname20), annual income is less than $15,000 (fieldname 2) and monetary assets is less than $3000 (fieldname 3) = value is 7000
Code:
if(fieldname16 < 2 && fieldname20 == No && fieldname2 < 15000 && fieldname3 < 3000) return 7000;b)
Condition:If one person household, with a finance plan, annual income is less than $15,000 and monetary assets is less than $3000 assets = value is 8400
Code:
if(fieldname16 < 2 && fieldname20 == Yes && fieldname2 < 15000 && fieldname3 < 3000) return 8400;c)
Condition:If one person household, with NO finance plan, annual income is between $15,000 and $35000, monetary assets is less than $3000 assets = value is 9000
Code:
if(fieldname16 < 2 && fieldname20 == No && fieldname2 >= 15000 && fieldname2 <=35000 && fieldname3 < 6000) return 9000;d)
Condition:
If one person household, with a finance plan, annual income is between $15,000 and $35000, monetary assets is less than $3000 assets = value is 10800Code:
if(fieldname16 < 2 && fieldname20 == Yes && fieldname2 >= 15000 && fieldname2 <=35000 && fieldname3 < 6000) return 10800;e)
Condition:
If one person household, with NO finance plan, annual income is more than $35,000, monetary assets is less than $3000 assets = value is 11000Code:
if(fieldname16 < 2 && fieldname20 == No && fieldname2 < 35000 && fieldname3 < 3000) return 11000;f)
Condition:
If one person household, with a finance plan, annual income is more than $35,000, monetary assets is less than $3000 assets = value is 13200Code:
if(fieldname16 < 2 && fieldname20 == Yes && fieldname2 < 35000 && fieldname3 < 3000) return 13200;g)
Condition:
If married or two person household, with NO finance plan, annual income is less than $25000 and monetary assets is less than $5000 assets = value is 7000Code:
if(fieldname16 > 1 && fieldname ==Yes fieldname20 == No && fieldname2 < 25000 && fieldname3 < 5000) return 7000;h)
Condition:
If married or two person household, with a finance plan, annual income is less than $25000 and monetary assets is less than $5000 assets = value is 8400Code:
if(fieldname15 == Married || fieldname16 > 1 && fieldname20 == Yes && fieldname2 < 25000 && fieldname3 < 5000) return 7000;i)
Condition:
If married or two person household, with NO finance plan, annual income is between $25000 and $50000, monetary assets is less than $10000 assets = value is 9000Code:
if(fieldname15 == Married || fieldname16 > 1 && fieldname20 == No && fieldname2 >= 25000 && fieldname2 <= 50000 && fieldname3 < 5000) return 9000;
j)
Condition:
If married or two person household, with a finance plan, annual income is between $25000 and $50000, monetary assets is less than $10000 assets = value is 10800Code:
if(fieldname15 == Married || fieldname16 > 1 && fieldname20 == Yes && fieldname2 >= 25000 && fieldname2 <= 50000 && fieldname3 < 10000) return 10800;
k)
Condition:
If married or two person household, with NO finance plan, annual income is more than $50000, monetary assets is more than $10000 assets = value is 11000Code:
if(fieldname15 == Married || fieldname16 > 1 && fieldname20 == No && fieldname2 > 50000 && fieldname3 > 10000) return 11000;l)
Condition:
If married or two person household, with a finance plan, annual income is more than $50000, monetary assets is more than $10000 assets = value is 13200Code:
if(fieldname15 == Married || fieldname16 > 1 && fieldname20 == Yes && fieldname2 > 50000 && fieldname3 > 10000) return 13200;**Objective: All in one Calculation so all conditions are met and a value is given to the user.
Thanks everybody!
- The topic ‘If statements, Multiple Conditions, && and ||’ is closed to new replies.