Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2012, 08:40 PM   PM User | #1
FIR93
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
FIR93 is an unknown quantity at this point
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
FIR93 is offline   Reply With Quote
Old 10-16-2012, 08:53 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 950
Thanks: 7
Thanked 98 Times in 98 Posts
WolfShade is an unknown quantity at this point
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 = 7-7
__________________
^_^

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".
WolfShade is offline   Reply With Quote
Users who have thanked WolfShade for this post:
FIR93 (10-17-2012)
Old 10-17-2012, 01:51 AM   PM User | #3
FIR93
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
FIR93 is an unknown quantity at this point
So for thee final answer y =4 and x=0 ?
FIR93 is offline   Reply With Quote
Old 10-17-2012, 02:50 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:50 PM.


Advertisement
Log in to turn off these ads.