Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mathcad Prime 2.0 Also if statement

Status
Not open for further replies.

engpes

Mechanical
Feb 10, 2010
175
I am trying to write an if / also if statement program in Mathcad prime 2.0. I have 2 variables x and z and I want to return a "yes" value if BOTH are positive.

I have attached the Mathcad file, but it is not returning the right result. If one of the values is negative, I want it to give a "no" output.

Thank you in advance for your help.

Thanks,
 
Replies continue below

Recommended for you

engpes,

While I am no Mathcad whiz, I believe that the x and z constraints (>0)should be combined together in an "and".
The first time your program receives a positive response (second line, z>0) it exits the conditional restraints and provides a "yes".
 
 http://files.engineering.com/getfile.aspx?folder=59056a3e-3f00-4bc3-9866-1c451cb8a579&file=else_if.xmcd
"Also if" is not what you want here. Also if is evaluated after an if-statement, no matter what the first if resulted. Thats different to "else if". But also if would not make for a logical AND. As already stated you would just combine the two constrains using the logical and.
I attached a second (not recommended) way using "else if". Also, while not absolutely necessary in this case, I recommend using the return statement.
 
 http://files.engineering.com/getfile.aspx?folder=c8f059da-a019-4f67-836e-f78ab42b5e37&file=Also_if_Statement_b.mcdx
Status
Not open for further replies.

Part and Inventory Search

Sponsor