Enjoy an ad free experience by logging in. Not a member yet? Register.


Results 1 to 4 of 4

10162012, 08:40 PM #1
 Join Date
 Oct 2012
 Posts
 2
 Thanks
 1
 Thanked 0 Times in 0 Posts
Working With If...Then Statements
I'm doing a homework assignment where I have to look at the code created by my teacher and write what the answer would be using the information given.
So x starts at 7
y starts at 12
Using the info below.
First she declared her variables and her statement looks like this:
If x <= 7 Or y > 11 Then
If x > 2 Or y > 9 Then
y = 4 * y + x
Else
y = x  8
If x + y > 14 Then
x = x  7
End If
End If
So looking at this the first If...Then statement is true then I go to the second one which is 'If x > 2 Or y > 9 Then'
and if that one is true as well I plug in my numbers to solve for 'y'. But do I use the same equation to solve for x as well?
Thanks for all help given
10162012, 08:53 PM
#2
 Join Date
 Apr 2012
 Location
 St. Louis, MO
 Posts
 985
 Thanks
 7
 Thanked 101 Times in 101 Posts
if 7 <= 7 OR 12 > 11 THEN // they both are
if 7 > 2 OR 12 > 9 THEN // they both are
y=4 * 12 + 7 //55
ELSE
y = 12  8 //4
IF 7 + 4 > 14 THEN // it isn't
x = 77
^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
Users who have thanked WolfShade for this post:
FIR93 (10172012)
10172012, 01:51 AM
#3
 Join Date
 Oct 2012
 Posts
 2
 Thanks
 1
 Thanked 0 Times in 0 Posts
So for thee final answer y =4 and x=0 ?
10172012, 02:50 AM
#4
 Join Date
 Sep 2002
 Location
 Saskatoon, Saskatchewan
 Posts
 16,979
 Thanks
 4
 Thanked 2,659 Times in 2,628 Posts
There is no way to tell with what you have here. Since you'll never enter that else statement, and there is mismatched end if with the if. . .then calls, there are. . . looks like 3 possible outcomes with the above algorithm. My personal answer with that above block is a compilation error.
Since the else can never be executed in the above code no matter how its written, y will always be 55, and x will be either 0 or 7.