Tech Today Online

Go Back   Tech Today Online > Knowledge Base > Ask the Experts


Reply
 
LinkBack Thread Tools Display Modes
Old 10-03-2010, 04:17 PM   #1
Junior Member
 
Join Date: Sep 2010
Location: NC
Posts: 9
Roxy is on a distinguished road
Default Making Decisions in Programming

Ok I thought structures were hard but decisions are horrible. Really confused on the if then else, and or, and when and how to understand when they are used. For example:
if department < 3 then
raise = SMALL_RAISE
else
if department < 5
raise = MEDIUM_RAISE
else
raise = BIG_RAISE
end if
end if

So would this be a SMALL_RAISE, MEDIUM_RAISE. or BIG_RAISE and why?

__________________
Members don't see ads in threads. Register your free account today and become a member on Tech Today Online, gaining access to posting privileges, contests, free plug-ins and other downloads, unlimited online storage for your photographs, reviews, free marketplace listings, and much more.
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
Reply With Quote
Old 10-07-2010, 02:18 PM   #2
Senior Member
 
jcjacob's Avatar
 
Join Date: Jul 2010
Location: Doylestown, PA
Posts: 159
jcjacob is on a distinguished road
Default

Roxy, what this is saying is:

assuming the department number are positive integers,

If you work in departments, 0, 1 or 2, you will get a SMALL_RAISE
If you work in department 4 you will get a MEDIUM_RAISE
If your department is 5 or anything higher, you will get a BIG_RAISE

Why:
a SMALL_RAISE is given if your department is LESS THAN 3 (0, 1 or 2)
a MEDIUM_RAISE is LESS THAN 5, but since 0, 1 and 2 were taken care of by the first IF, that only leaves 4
If your department is anything else (5 or greater) it is assigned BIG_RAISE by the last ELSE which catches all other conditions.

Make sense?
__________________
-John
jcjacob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
Reply With Quote
Old 10-07-2010, 09:35 PM   #3
Junior Member
 
Join Date: Sep 2010
Location: NC
Posts: 9
Roxy is on a distinguished road
Default

Yes that does make sense. Why couldn't you be my teacher???? I appreciate your help and hope you don't think I am to dumb.
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
Reply With Quote
Old 10-08-2010, 05:33 AM   #4
Senior Member
 
jcjacob's Avatar
 
Join Date: Jul 2010
Location: Doylestown, PA
Posts: 159
jcjacob is on a distinguished road
Default

Glad to be of help Roxy.
The problem with learning structured programming is that we learn to process lots of information simultaneously to make decisions (sight, sound, touch, smell, etc.). In programming, the computer only executes one single instruction at a time, so breaking everything down to it's most basic component can be a challenge. It just takes practice so stick with it and you'll be fine.

The only dumb question is the one you never ask.
__________________
-John
jcjacob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding Structure in Programming Roxy Ask the Experts 8 09-22-2010 03:11 PM


All times are GMT -5. The time now is 09:24 PM.