Programming | | Notes on the NULL ELSE, AND, and the OR Logical Operators: |
The
NULL ELSE: - is used when there is processing on the true path only. When the
tested condition is not true, no special alternative action is required. The
true path will perform some type of processing or output. The false path goes
directly to the connector symbol. Having no condition after the keyword ELSE
represents the no-function condition. It is immediately followed by the keyword
ENDIF. Having the keyword ELSE is optional and in fact the program will still
run if you do not apply it within the code.
But it must be used if you do have information that must be processed in the
false path. For good practice always apply the keyword ELSE within all programs that have the IFTHENELSE
structure. Below you will see an
example of a flowchart and a Visual Basic program. Flowchart
IFTHENELSE Null Example:
Logical Operators:
are used to combine conditions in an
IF statement. Logical operators
that are commonly used include AND, OR, and NOT.
The use of these logical operators is explained next. The AND logical
operator uses the word AND to mean two or more specified conditions are true in
an expression. The program below
will allow you to check to see if the two variables you entered are required. Depending
on what hours and employee code you actually entered, the program will output a
statement on both true and false paths. The AND Logical Operators – For review only: You will NOT code the below Console Application just for review of this concepts.
The
OR logical operator is used to indicate that if either or both conditions
are true, then the IF statement is considered true and will follow the true
path. Below shows how the OR
operator can be applied within the IF Statement.
The
OR Logical Operators – For review only: You will NOT code the below Console Application just for review of this concepts:
Adding
Processing steps to this problem – For review only: You will NOT code the below Console Application just for review of this concepts:
Compute
the pay for an employee, assuming that name, Employee's Code, and hours worked
are as input. The output will be
pay for the employee. You will
notice that the steps to compute the employee's pay will be based on the same If
statement.
Programming - Example Problem #8: (NULL ELSE, AND, and OR Operators): Example Problem 8: This is a simple program that will use the IFTHENELSE structure that will allow the IF structure to make two or more combine conditions in a single IF statement. The example of the form will show a few textboxes, buttons and a few labels. Using the above structure and concepts to program this in a Window Application. Please remember to place your name somewhere at the bottom of this form and put a Flowerbox at the top of the code. Save the program as Example 8 and put the form and code together. Please Note: When turning in this Example problem 8 you will need to turn in the Form (during run time) and Code.
The NULL ELSE
- Example 8A:
In this example problem you are testing to see if the employee worked 40 hours. In addition, you are to compare the flowchart with the code. Notice that there are no steps in the false path. This is called a NULL ELSE. ![]()
Example Problem 8B - You will write this Example Problem 8 by using the below code for this Window Application program. The above code was just to show how the Logical Operators can be used to test to or more inputs. This program will be written in Window Application.
Here is a closer look at what the program code for this a Window Applications.
Below is the Example Problem 8B The code needed for this example problem.
Flowerbox Template: Put the flower box into the code as shown above.
Also please code the Clear and Exit Button in this program. Once you get the code entered try to run the program to get it working. Keep this simply by using the following Desk Check input below. Please note that you will need to type in a caps A, B, or C for the for the Employees Code. I also ask you to run it and test it many different ways. maybe try entering in a lower case a or b to see the output.
Notes The UCase and LCase Functions - Example Problem 8C: You will need to review these notes to see how UCase and LCase Functions is used with the code to make the program more user friendly.
Review the Link for the Example Problem 8C - You need to continue review the next set of code:
Notes The UCase and LCase Functions- Example Problem 8C:.
The Desk Check - You will see three different desk check below. Once your program is running try to enter in the inputs to capture the output to the following and present the screen shots to this example problem.
Teacher
Comment: So far you have learned
quite a bit of some of the most important concepts of Basic programming. If you
have understood everything so far, then well done. If you are a little skeptical
and unsure, don't worry and keep an open mind and keep trying. |