(conditional test) (action if true) It is common to place the above selection statement in an If block, as follows:

Size: px
Start display at page:

Download "(conditional test) (action if true) It is common to place the above selection statement in an If block, as follows:"

Transcription

1 Making Decisions O NE OF THE MOST IMPORTANT THINGS that computers can do is to make decisions based on a condition, and then take an action based on that decision. In this respect, computers react almost like humans. Humans are faced with thousands of decisions each day, and our actions are usually based on the decisions we make. For example, we must decide: what to wear? Where to go? When to go? What to eat? What to say? and so on. Let s take a closer look at how we make decisions. When we are faced with a decision to make, we look for a condition, and the results of the test directs our action. For example, if the weather is cold outside, we wear a coat. The condition (cold weather) directs our action (wearing a coat). Putting it another way, we could say: If the weather is cold outside, then it is true that a coat should be worn. This is a simple decision with one condition, and one action. We could give a second action if the decision turns out the other way: If the weather is cold outside, then a coat should be worn, otherwise wear cooler clothing. In 93

2 this case, if the test determines that the condition is false (the weather is not cold) then the second action is performed. A computer can be programmed to also evaluate a condition, and then select the appropriate action to take based on the outcome of the test. This is called a selection statement because the computer must select between the two alternatives. The programmer must phrase the conditional test so that the answer will be either True or False. The computer will then select the true action if the test evaluates to true, and the false action if the test evaluates to false. It will not do both actions. The If Statement tement A computer can evaluate a condition, and then select the appropriate action based on the outcome of the test. The most basic selection statement in programming is the If statement. It starts with the keyword If, and then gives the conditional test. (The conditional test will evaluate to either true or false). Next comes the keyword Then and it is followed by the action to perform if the test evaluates to true. In programming syntax, the statement becomes: If weather is cold Then wear a coat (conditional test) (action if true) In the above test, if the conditional test evaluates to false, nothing will happen because the specified action can only take place if the test evaluates to true. If the statement is relatively short and only has one action, then the entire statement can be placed on a single line. It is common to place the above selection statement in an If block, as follows: If weather is cold Then wear a coat The line signals the end of the selection statement. The If block is more common because it is easier to read. When two or more items are included in the actions-if-true portion, then the block of lines must be used. For example 94 If weather is cold Then wear a coat take a hat take an umbrella

3 The If Statement tement Frequently, one action is performed if the statement evaluates to true and a different action is given if the statement evaluates to false. This can be accomplished using the If selection statement. For example: if the weather is cold outside, wear a coat otherwise wear cooler clothing. The pseudocode for this statement placed in the block syntax would be If weather is cold Then wear a coat take a hat take an umbrella wear cooler clothing take sun glasses In the If block, the conditional test is evaluated. If the result is true then the items found between the Then and keywords is performed; the items between the and keywords are skipped. If the result is false, then the items between Then and are skipped and the items between the and is performed. The actions found between the Then and keywords is called the True path, and the actions between the and is called the False path. Figure 5.1 Flowchart of the If Block The above pseudocode is frequently used, and the If and If blocks can also be shown using flowcharting symbols to graphically display the True and False paths. Figure 5.1 shows the If block, and figure 5.2 on the next page shows the If block. Figure 5.1, the If Selection Structure, shows the flow of control entering the decision symbol (the diamond) from the oval symbol. The test is then evaluated. If the test evaluates to true, the 95

4 Figure 5.2 Flowchart of the If Then Block flow of control takes the True path, then performs the actions shown in the box. The flow then continues to the next item shown as End in the lower oval in both figures above. If the test evaluates to false, it takes the false path and continues to the next statement without doing the items in the box. In Figure 5.2, the If- Selection Structure, the test is evaluated, and the flow of control takes only the appropriate true or false path, and does the actions listed in the box in its path. The flow then continues to the next item the lower oval in the figure. Coding If-Then- Statements tements The syntax for coding the If-Then- Selection Structures is shown below. The first block shows the general case in words and the second block shows an example of actual code. General case: If (condition) Then statements to be processed if the test evaluates to true statements to be processed if the test evaluates to false 96

5 In the general case block, the items in bold are required keywords, and the items in italics are supplied by the programmer. The conditional test must be able to be evaluated to either true or false. The programmer will have several options in the way to structure the test using relational operators. Syntax example: If decsales > 1000 Then decrate = decsales *.1D decrate = decsales *.05D In the syntax block, if the amount in decsales is greater than 1000 then decsales will be multiplied by.1. However, if decsales is not greater than 1000 then decsales will be multiplied by.05. Rela elational Operator tors Relational operators are used to determine the relationship between two options. The result of a relational test can only be evaluated as true or false (also called a Boolean expression). Only six relational operators are available, and they are shown in Table 5.1 Table 5.1 Relational Operators Symbol Meaning Example = equal to A = B > greater than A > B < less than A < B >= greater than or equal to A >= B <= less than or equal to A <= B <> not equal to A <> B It is important to note that both options in the expression (shown as A or B in table 5.1) must be similar in nature. That means that both options can be numeric values, or text strings, or properties of objects, but comparing strings against numeric values is not allowed. Numeric comparisons are easy to understand. Negative values are less than zero and also less than positive values. Comparisons of text strings, however, compare the strings letter by letter using the ANSI value of text characters. In text string comparisons, the case of the letter is important. For most computers, capital letters come before lower case 97

6 letters. So the test A < a would be evaluated as true and A = a would be false. Also, for text strings, nothing comes before something so the is less than then. Comparing Uppercase and Lower ercase Since an uppercase A and a lowercase a characters are not equal to each other, we must have a way to compare similar cases if the case should be disregarded. To do this, we convert them to the same case using the ToUpper or ToLower methods. For example, if you need to compare two text strings, such as vb and VB, the all uppercase string would be considered as lower or first in order. To correct this from occurring, append the ToUpper to both, and then the comparison will compare character differences and not compare cases. Assume you want to compare the string variable VB to a textbox entry that could be entered as vb or Vb as well as VB. The code would be: If txtprogram..toupper = VB Then do something would evaluate to true. In this example, the case entered by the user would not matter -- the test would evaluate the characters without regard to its capitalization.. Nested If Statements tements Multiple questions are generally a series of nested true-false questions followed in sequence. Frequently one question follows another to form a chain of questions. This can present a multiple-way comparison instead of a two-way comparison with the standard If statement. Multiple questions are generally a series of nested true-false questions followed in sequence. This can be shown graphically in the flowchart shown in Figure 5.3 on the next page. From figure 5.3, the first question is Is the sun shining? If the answer is false, then we stay home and study. However, if the answer is true, then we ask another question: Is the temperature greater than 80 degrees? If the answer to this question is true, then we go to the beach to enjoy to sun. If the answer is false, then we go to the library to study. 98

7 Figure 5.3 Flowchart of a Nested If-Then- Block Coding Nested If-Then- Statements tements The syntax for coding the nested If-Then- Selection Structures is shown below. The first block shows the nesting under the true option general case in words and the second block shows actual code. Notice that the nested statement is a complete If-Then- structure, and replaces the true option. General case: Nested If If (condition-1) Then If (condition-2) Then statements to be processed if both tests evaluate to true statements to be processed if the first test evaluates to true and the second test evaluates to false statements to be processed if the first test evaluates to false 99

8 Syntax example: If decsales > 1000 Then If decsales > 1500 Then decrate = decsales *.15D decrate = decsales *.1D decrate = decsales *.05D In this example, the nesting portion allows a three-way test. The first test tests if sales are greater than If true, then the second test tests if sales exceed If this second test is true, then the rate is 15%. If the second test is false, then the rate is 10%. If, however, the first test was false, the rate is 5%. The nesting could have been placed in the portion instead of the Then portion, and it would work nearly the same way. Or, nesting can occur in both options. Nesting within nesting can also occur. The more nesting occurs, the more complicated the logic becomes. The he If For orma mat Similar to the Nested If structure is the If structure. The If replaces a series of nested if statements with additional if statements, and the process continues until a true answer is found. If no true answer is found, then the statement is used. Most programmers find the If format easier to follow, and it is more common in programming than a series of nested if statements. The structure for coding the If format is shown below. The first block shows the general case in words and the second block shows an actual code example. The If replaces a series of nested if statements with additional If statements 100 General case: If (condition-1) Then statements to be processed if the first test evaluates to true If (condition-2) Then statements to be processed if the second test evaluates to true statements to be processed if all other tests evaluate to false

9 Additional If statements can be used as long as they are placed above the statement. Syntax example: If decsales > 1500 Then decrate = decsales *.15D If decsales > 1000 Then decrate = decsales *.1D decrate = decsales *.05D With the If structure, the testing continues until a true option is found. If no tests evaluate to true, then the option is used. Also notice that in the If structure, there is only one If statement, followed by an unlimited number of If statements, just one statement, and just one statement. The If structure usually results in easier logic to follow, and fewer lines of code. Comparati tive e Examples To show the programming differences between the nested-if and If formats, let s show a programming example of each option. The If statements will determine the class standing of a student based on the number of units completed. Nested-If example: Dim decunits as Decimal If decunits < 32D Then lblclass. = Freshman If decunits < 64D Then lblclass. = Sophomore If decunits < 96D Then lblclass. = Junior lblclass. = Senior 101

10 If example: Dim decunits as Decimal If decunits < 32D Then lblclass. = Freshman If decunits < 64D Then lblclass. = Sophomore If decunits < 96D Then lblclass. = Junior lblclass. = Senior In the Nested If example, each If block is complete with each block starting with If and ending with corresponding. The number of End Ifs must equal the number of Ifs. Each If block is indented. This example took 13 lines of code. In the If example, there is only one If and only one. The serves as the false option for all Ifs. This second example took only 9 lines of code. Both formats will accomplish the same result, and the format to use is usually the programmer s choice. Testing for Compound Conditions Sometimes you need to make a more complex test by testing a compound condition, such as having two conditions being true at the same time. This requires the use of Logical operators. The logical operators are And, Or, and Not. Table 5.2 gives examples of each. Table 5.2 Table of Logical Operators Logical Operator Meaning Example Explanation And Both conditions If A > 0 And Evalates to True if must be true If A < 10 the values are: 1, 2, for the test to 3, 4, 5, 6, 7, 8 or 9 evaluate to True Or If either condition If A = 1 Or Evaltes to True if is True, the test If A = 2 the values are evaluates to True either 1 or 2 Not Reverses the condition If Not A = 0 Evaluates to True if so that a True answer the values is any shows False, and False thing other than 0 answer shows True 102

11 Logical operators give the programmer the ability to apparently make two decisions at one time. However, this really isn t the case. When using logical operators, the tests are actually performed one at a time but both tests are performed before an action takes place. So if the test is If A > 100 And B > 50, the first test is evaluated, then the second test is evaluated, and then if both evaluate to True, the true action is processed. However, if the first test evaluates to True and the second test evaluates to false, then the false action is processed. On the other hand, if the first test is false the second test is not performed, and the false action is processed. Let s go through a pseudocode example on voting using the And operator: If Age >= 18 = True And RegisteredToVote = True Then Message = You can vote Message = You cannot vote In the above example, to be eligible to vote, both conditions must be true. This second pseudocode example will show the Or operator: If Age < 10 = True Or Age > 64 = True Then Message = Discounted Admission Price Message = Regular Admission Price In this example, the discounted price is given to either children under age 10 or adults over age 64. The third pseudocode example shows the Not operator which reverses the True or False response: If Not Age > 0 Then Message = Not a valid age In this example, if the age is less than zero, then the not a valid age message is shown. That would test for a negative value in the age data. If the If block also had an portion, then using the Not operator has the 103

12 same affect of putting the false action in the true portion, and vice versa. Sometimes the logic is hard to follow, but in some cases it is easier to test for bad data than to test for good data. The purpose of the And, Or and Not logical operators is to give flexibility to the programmer. Sometimes it is easier to use Logical operators than to use multiple nested If or If blocks. The disadvantage of logical operators is that the logic can be more complex. But when the situation fits, it can be a useful programming strategy. The Select Case Decision Structur ucture Another decision making structure is the Case model. This structure presents one variable and then gives several mutually-exclusive paths to follow depending upon the value in the test. It is sort of like a multiple choice question on an exam: the stem presents the topic (or question or value), and then several alternatives are presented. The alternative or path taken is the first in the group that qualifies. The path to follow can be a single value or a range of values. The structure for coding the Select Case format is shown below. The first block shows the general case in words and the second block shows an actual code example. The Select Case is sort of like a multiple choice question on an exam: the stem presents the topic, and then several alternatives are presented. General case: Select Case value Case 1 statements to process if the first case is true Case 2 statements to process if the second case is true Case 3 statements to process if the third case is true Case 4 statements to process if the fourth case is true Case statements to process if all other cases evaluate to false End Select 104

13 Syntax example: Select Case intsales Case 1 To 1000 decrate = intsales *.05D Case 1001 To 1500 decrate = intsales *.1D Case Is > 1500 decrate = intsales *.15D Case only possible is a zero or a negative value decrate = 0.0D End Select In both of the above examples, only one path is possible, and the program finds the appropriate path and follows it. A flowchart for the Case Select decision structure is shown in Figure 5.4: Figure 5.4 Flowchart of Select Case Structure 105

14 The value in the Select Case opening line is typically a variable. There is no limit to the number of items to match in a Select Case statement. The items to match can be a single value, a range of values, or a relational condition. Examples of the syntax for these items are shown in Table 5.3: Table 5.3 Syntax Options for Select Case Structure Option Example Comment Single item Case x Multiple single items Case x, y, z Separate items by commas Range of values Case x To y Keyword To is required Relational expression Case Is > x Keyword Is is required string item Case abc Item must be enclosed inside double quotes When using the Select Case format, the Case option is optional. However, it is wise to use it to catch anything that doesn t otherwise qualify. Frequently programmers use the Case option to provide a Message Box statement indicating that invalid or out-of-range data was used. Decision Message e Boxes es The difference between an Informational Message Box and a Decision Message Box is whether the user can make a choice between alternatives. Chapter 4 introduced the concept of Informational Message Boxes. They provide an easy way to provide information to the user without having to write a message to an output label. This portion of this chapter will take it a step further, and explain how to use Decision Message Boxes. The primary difference between the two is that the Decision Message Box expects the user to make a choice between two or three alternatives. As a review, there are four parts to a Message Box: (1) the Caption, (2) the text message, (3) the button (or buttons), and (4) the icon. Informational Message Boxes have just one button the OK button. Decision Message Boxes have two differences from Informational Message Boxes: (1) they have either two or three buttons, and (2) the text message is a question rather than a statement. A typical Decision Message box having three buttons and the question mark icon is shown in Figure 5.6 on the next page. 106

15 Figure 5.6 Example of a Decision Message Box Message Boxes are displayed using the MessageBox.Show method. The general format is: MessageBox.Show(, Caption,button,icon). The actual code used to display the Message Box shown in Figure 5.6 is as follows: MessageBox.Show( Are you sure you wish to _ & end this program?, Warning, _ MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Question) For Decision Message Boxes, the four icon choices and the code segment to use to show them are shown in Figure 5.7: Figure 5.7 Icons to be Ussed With Decision Message Boxes MessageBoxIcons.Information MessageBoxIcons.Exclamation NessageBoxIcons.Stop MessageBoxIcons.Question In addition to the OK button (which isn t appropriate to use on the Decision Message Box), the other buttons combinations are: 107

16 Figure 5.8 Button Combinations for Decision Message Boxes The challenge the programmer has when using Decision Message Boxes is twofold: (1) to phrase the text argument in the form of an appropriate question, and (2) to select the appropriate response buttons. If the user needs to make a decision, and all they have for a response is the OK button, then the programmer has blown it. Likewise, on an Informational Message Box, if the user is given extra buttons that make no sense, the user will be confused. The code to display the button combinations are: MessageBoxButtons.OK MessageBoxButtons.OKCancel MessageBoxButtons.RetryCancel MessageBoxButtons.YesNo MessageBoxButtons.YesNoCancel MessageBoxButtons.AbortRetryIgnore After displaying the Decision Message Box, the user must respond by selecting one of the above buttons displayed in the message box. That will close the message box and an Integer value and a DialogResult constant are returned corresponding to which button the user selected. Using the DialogResult constant can be used to determine the appropriate action to take based upon the user s response. Table 5.4 shows the DialogResult constants and Integer value returned by clicking the message box button. 108

17 Table 5.4 Return value given by user clicking on a Message Box button DialogResult Integer constant value User action DialogResult.OK 1 user clicked the OK button DialogResult.Cancel 2 user clicked the Cancel button DialogResult.Abort 3 user clicked the Abort button DialogResult.Retry 4 user clicked the Retry button DialogResult.Ignore 5 user clicked the Ignore button DialogResult.Yes 6 user clicked the Yes button DialogResult.No 7 user clicked the No button Note: The DialogResult constant should be used rather than the Integer value because the constant makes the code easier to read and understand. By declaring a variable to capture the returned Integer, and actually capturing the variable can allow its use in an If or If-Then- statement block, as shown in Figure 5.9: Figure 5.9 Code to display a Decision Message Box, and to use the return value to direct an action In the code shown in Figure 5.9, the variable intdmbyesno (DMB is a programmer s shortcut for Decision Message Box) is the variable to capture the value 6 if the user clicks the Yes button or the value 7 if the user clicks the No button. Then the intdmbyesno = MessageBox.Show line displays the message box and captures the dialog.result value. The If- Then- block then carries out the users input. This is a classic case of a decision block where one thing is done based on a value and something else is done if the value is different. In the example above, if the user clicked the Yes button, then the program is terminated. However, if they click either the No or Cancel buttons, nothing happens since there is no programming to handles the No or Cancel buttons, and the program continues. 109

18 Input Boxes An Input Box is another convenient way of entering data in the program while the program is running. You could say that it is a combination of a Message Box and a Box control. An Input Box displays a message, two buttons an OK button and a Cancel button, and has an input area where the user can enter information. Figure 5.10 shows an example of an Input Box. Figure 5.10 Sample Input Box Title Prompt Buttons Area A function is a predefined routine that performs an action and returns a value. Technically an Input Box is a function. A function is a predefined routine that performs an action and returns a value after completing the action. The action is to display the Input Box, and the return value is a text data string. If the user clicks the OK button, the returned value is the text characters entered in the input area. However, if the user clicks the Cancel button or the close button, an empty data string is returned. Since the returned data is a String data type, a String variable needs to be declared and used to capture the returned data. Similar to a Message Box, the Input Box has four parts: 1. the Title at the top, 2. the Prompt in the main area, 3. the OK and Cancel buttons, and 4. the input area. The programmer can place a default response that is highlighted in the text input area. The user can accept the default response by clicking the OK button, or change the response and then click the OK button. The code to produce the Input Box shown above in Figure 5.10 is: 110

19 Dim strname As String strname = InputBox( Please enter your name, _ Name please ) The Input Box in Figure 5.10 does not include a default response. If a default response is used, it would be the third argument inside the parentheses, and it would be enclosed in double quote marks since it is a text string. A comma is used to separate the arguments. Hands-On Programming Example This chapter s hands-on project is a Pizza shop s order form. You should attempt to complete the project on your own without looking at the solution provided here. The more you can do on your own without looking at the text, the better your mastery of the topic will be. Do as much as you can on your own, and then check your results against the project that follows. Step 1 Plan the Project The he Project The task is to complete a pizza order form for Solano Pizza that will allow the order taker to indicate the customer s preferences in pizza toppings, size, and whether the customer will eat the pizza on the premises, take it home, or have it delivered. If they indicate it is for delivery, then the order taker will need to get the street address, city, and telephone number. The project will also compute the price of the pizza. The pricing structure includes cheese and two free toppings. The medium size pizza costs $14.95, the large pizza costs 18.95, and the extra large costs Additional toppings will cost.95 cents each. The delivery charge is $3.00. Assume that no taxes or other charges exist. The order form will not show the controls for the address and phone number unless the customer indicates that the pizza will be delivered. Then the delivery information will display at the bottom of the form. 111

20 Planning the Action The order taker will click a check box for each topping requested by the customer. The order taker will also select a radio button for the pizza size. A separate set of radio buttons will indicate the delivery, take out or eat in plans. Clicking on the Price button will compute the total price of the pizza which considers the extra toppings, size, and any delivery fees. Clicking on the Clear button will clear all controls and reset the form for the next customer. Clicking on the End button will terminate the program. When the Deliver radio button is selected, the delivery information will become visible. Pseudocode The pseudocode for the Price button will be: 1. Declare the needed variables. 2. Read the settings for the pizza toppings selected. 3. Read the radio buttons for pizza size. 4. Read the radio buttons for delivery, eat in, or take out. 5. Determine the number of toppings selected. 6. Determine the number of extra toppings. 7. Determine the pizza base price by size. 8. Add charge for extra toppings (if any). 9. If delivery is selected, add charge for delivery. 10. Display formatted price on form. The pseudocode for the Delivery radio button will be: 1. Display address lines on form. 2. Notify the customer if price changes dues to delivery charge The pseudocode for the Clear button will be: 1. Remove check mark from all toppings boxes 2. Reset the size radio button to Medium. 3. Reset the delivery radio buttons to Eat In 4. Remove text from all address lines. 5. Hide address lines from view. 6. Set focus to Price button. The pseudocode for the Exit button will be: 1. Terminate the program 112

21 Step 2 Create the User Interface Popula opulating the For orm Place the following objects on the form, and arrange them to match Figure 5.11: 6 Labels 6 Check Boxes 3 Group Boxes 3 Buttons 3 Radio buttons (place inside group box 1) 3 Radio buttons (place inside group box 2) 3 Boxes (place inside group box 3) Setting the Proper operties Set the following properties for each object: Object Property Setting Form Pizza Order Form AcceptButton btnprice CancelButton btnclear StartPosition CenterScreen Label1 Name (unnamed) Solano Pizza Font.Size 24 pt. Font.Style Bold CheckBox1 Name chkpepperoni Pepperoni CheckBox2 Name chksausage Sausage CheckBox3 Name chksalami Salami CheckBox4 Name chkmushrooms Mushrooms CheckBox5 Name chkolives Black Olives Properties continued on next page 113

22 Object Property Setting (Continued) CheckBox6 Name chkcheese Extra Cheese GroupBox1 Name grpsize Size RadioButton1 Name radmedium Medium Checked True RadioButton2 Name radlarge Large Checked False RadioButton3 Name radxlarge Extra Large Checked False GroupBox2 Name grpdelivery Delivery RadioButton4 Name radeatin Eat In Checked True RadioButton5 Name radtakeout Take Out Checked False RadioButton6 Name raddelivery Delivery Checked False Label2 Name (unnamed) Price: Label3 Name lblprice (blank) AutoSize True BorderStyle Fixed3D FontSize 14 pt. FontStyle Bold 114 Button1 Name btnprice &Price Properties continued on next page

23 Object Property Setting (Continued) Button2 Name btnclear &Clear Button3 Name btnexit &Exit GroupBox3 Name grpaddress Delivery Address Label4 Name (unnamed) Street Label5 Name (unnamed) City Label6 Name (unnamed) Phone Box1 Name txtstreetadd (blank) Box2 Name txtcity (blank) Box3 Name txtphone (blank) Step 3 Write the Code You will need to write the code for each of the following event procedures. Start by writing the comment lines which come from the pseudocode: Event Procedure btnprice_click Comment Lines (from the Pseudocode) Determine the sales price of the pizza Declare variables Determine the number of toppings ordered Determine the number of charged toppings Set price by size Add in delivery fee Compute results Display price in label 115

24 Comment Lines (Continued) Event Procedure raddeliver_checkchanged btnclear_click btnexit_click Comment Lines Reveal delivery information Display message box if price changes Resets for controls to original state Resets focus to Price button Terminates the project Figure 5.11 Completed Pizza Order Project User Interface 116

25 Writing the Event Procedur ocedure e Code Project Comment Lines Program Title: Pizza Order Form Programmer: Don Hoggan Description: This program will compute the price of a pizza ordered considering the pizza size, number of toppings, and whether it needs to be delivered. Public Class frmpizzaorder btnprice_click event procedure Private Sub btnprice_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnprice.click Determine the sales price of the pizza Declare variables Dim decprice As Decimal Price accumulator Dim inttoppings As Integer Toppings counter Determine number of toppings ordered If chkpepperoni.checked Then inttoppings = inttoppings+1 If chksausage.checked Then inttoppings = inttoppings + 1 If chksalami.checked Then inttoppings = inttoppings + 1 If chkmushrooms.checked Then inttoppings = inttoppings+1 If chkolives.checked Then inttoppings = inttoppings + 1 If chkcheese.checked Then inttoppings = inttoppings + 1 Determine the number of charged toppings If inttoppings < 3 Then inttoppings = 0 inttoppings = inttoppings - 2 Set price by size If radmedium.checked = True Then decprice = 14.95D If radlarge.checked = True Then decprice = 18.95D decprice = 23.95D Code continued on next page 117

26 btnprice_click event procedure (continued) Add in delivery fee If raddeliver.checked = True Then decprice = decprice + 3D End Sub Compute results decprice = decprice + (inttoppings * 0.95D) Display price in label lblprice. = decprice.tostring( C ) raddeliver_ CheckedChnged event procedure Private Sub raddeliver_checkedchanged(byval sender As System.Object, ByVal e As System.EventArgs) Handles raddeliver.checkedchanged Reveals delivery information If raddeliver.checked = True Then grpaddress.visible = True grpaddress.visible = False MessageBox.Show( The Price has changed, _ Pizza Order, MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation) End Sub btnclear_click event procedure Private Sub btnclear_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.click Resets the form chkpepperoni.checked = False chksausage.checked = False chksalami.checked = False chkmushrooms.checked = False chkolives.checked = False chkcheese.checked = False radmedium.checked = True radeatin.checked = True txtstreetadd.clear() txtcity.clear() txtphone.clear() grpdelivery.visible = True lblprice. = btnprice.focus() 118

27 btnexit_click event procedure End Sub Private Sub btnexit_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.click Terminates the project Me.Close() End Sub End Class Step 4 Test and Debug the Program 1. When running the program, the form should center on the screen with the Medium and Eat in radio buttons being checked, no check boxes checked, and the price label empty. The delivery address group box should not be showing. 2. Click on the Price button with Med. Size and no extra toppings, and the Eat-in option, and the price should show as $ Select the following options, and click on the price button: a. Any four toppings, Large size, eat-in: $20.85 b. Any five toppings, Medium size, eat-in: $17,80 c. All six toppings, Extra Large size, eat-in: $27.75 d. All six toppings, Extra Large size, delivered $30.75 e. Any 2 toppings, Medium size, take out $ Click on the Deliver radio button, and the Delivery Address group box should show. When you click on the Take Out or Eat-In buttons, the Delivery Address group box should disappear. 5. Click on the Clear button, and all check boxes should be unchecked, and the Eat-in and Medium size radio buttons should be checked. If the Delivery button was checked before clicking on the Clear button, a message box should show informing the user that the price has changed. The price label should be blank. 6. Test the tab sequence and Keyboard Access keys. 7. Click the End button and the project should terminate. 119

28 Chapter Summary 1. Computers can be programmed to evaluate conditions and then select the appropriate action to take based on the outcome of a conditional test. 2. Conditional tests can be evaluated as being either true or false. 3. In a conditional test, the program will do a specific action if the test evaluates to true and a different action if it evaluates to false. 4. An If-Then- block is used to separate the true and false paths. 5. Relational operators are used to determine the relationship between two options. 6. The ToUpper or ToLower methods are used to ensure that text comparisons compare the text character but not the text case. 7. Multiple If statements can be nested to allow a series of decisions to be made before the action takes place. 8. Nested If statements can be placed in the true path, the false path, or both paths. 9. If statements allow a different test to be considered before taking the action. If statements are generally easier to use than a series of nested If statements. 10. Logical operators allow a more complex testing situation, such as two items both being true, or one of two items being true (or false). 11. The Case Select decision structure is like a multiple choice question the first alternative that qualifies is the path taken. 12. A Decision message box expects the user to make a decision between two or three alternatives when responding. The response can be captured and used to take alternative paths of action. 13. An Input box is a mix between a message box and a text box control, and can be used as a form of data input. Key Ter erms Case Select If-Then- Prompt Conditional test Input Box Relational operators Decision Message Box Logical operators ToUpper/ToLower If Nested Ifs 120

29 Revie view Questions 1. What are the two possible outcomes of a conditional test? 2. What is the syntax of an If-Then- block? What keywords are required, and on what lines do they appear? 3. What happens if you forget to keyboard the keywords in an If block? 4. What are the six Relational operators? 5. Why is it more difficult to compare text characters than numbers? 6. Are capital letters considered to be higher or lower than lower case letters when comparing similar characters? 7. What term is used to describe a series of decisions to be made before taking the appropriate action? 8. What is the difference between using nested If statements or If statements? 9. What are the logical operators that allow for testing a compound condition? 10. How does using the Not logical operator affect the conditional test outcome? 11. How does the Case Select decision structure differ from an If-Then- format? 12. What is the correct syntax with the Select Case format for the following items: a. a single item b. multiple single items c. a range of items d. relational expressions e. text string items 13. What is the key difference between a decision message box and an informational message box? 14. What are the button combinations that can appear on a Decision message box? 15. What icons can be used with Decision message boxes? 16. What is returned to the program when using an Input Box when the user clicks the OK button? Cancel button? 121

30 Voca ocabular ulary Cross osswor ord Solve the crossword puzzle using the clues below. All terms are in this chapter or previous chapters. ACROSS 1. The method to convert text characters to upper case letters. 3. An alternative to using nested If statements. 4. A test will evaluate to either true or false. 6. The message box type that expects the user to select between two or three buttons when responding. 7. A selection structure block that evaluates a test and takes the appropriate action based upon the test results. (three words) 8. A operator allows a more complex test by testing for Or, And, and Not conditions. DOWN 2. Any of six operators can be used to determine whether a test is true or false. 4. A decision structure similar to a multiple-choice question on a test. (two words) 5. A series of decisions to be made before taking the action is referred to as a If statement. 9. An can be used for data input, and is similar to a message box. 122

31 Programming Practice Exercise 5-1. Job Applicant Screening Assume your employer has placed an ad to gain applicants for a job opening in your company. He/she has set the categories, and weighted the various criteria with points. He/she would like you to create a screening form containing the criteria by category, and set it up so the information on each candidate can be entered, and the program will tally the total points awarded, and evaluate the points. Candidates receiving more than 20 points will be rated Desirable, candidates receiving between 10 and 20 points will be Possible, and those receiving less than 10 points are Unacceptable. Set up the form to use a group box for each category, and a radio button for each criteria within the category. The categories and criteria are: Category Criteria Value Education level 4 Years of College 5 2 Years of College 3 High School Grad 1 Not High School Grad 0 Education field Engineering 5 Business 3 Other 1 Experience in years More than 5 years 5 3 to 5 years 3 Less than 3 years 1 Experience in field Manufacturing 5 Sales 3 Other 1 Computer experience Yes 5 No 0 Your form should not show the point values. The form should show the name of the candidate, the total score in points, and the rating. The tally should be computed when clicking on a Compute button. Also include buttons to Reset the values for a new candidate, and to terminate the program. Be sure to set one radio button in each category to be on. Center the form when it is run, set an appropriate tab sequence, use proper control names with prefixes, declare the necessary variables, and set the focus. Hint: Use If-If blocks for each category, and the Select Case to display the rating term. 123

32 124

Fast Food Store Group Boxes and Other User Controls

Fast Food Store Group Boxes and Other User Controls VISUAL BASIC Fast Food Store Group Boxes and Other User Controls Copyright 2014 Dan McElroy Sample Program Execution The customer receipt is updated each time another selection is made and the Enter button

More information

Final Exam 7:00-10:00pm, April 14, 2008

Final Exam 7:00-10:00pm, April 14, 2008 Name:, (last) (first) Student Number: Section: Instructor: _P. Cribb_ L. Lowther_(circle) York University Faculty of Science and Engineering Department of Computer Science and Engineering Final Exam 7:00-10:00pm,

More information

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme

4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme Chapter 4: 4.1 Making Decisions Relational Operators Simple Program Scheme Simple Program Scheme So far our programs follow a simple scheme Gather input from the user Perform one or more calculations Display

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

Chapter 4: Making Decisions

Chapter 4: Making Decisions Chapter 4: Making Decisions CSE 142 - Computer Programming I 1 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >=

More information

Full file at https://fratstock.eu Programming in Visual Basic 2010

Full file at https://fratstock.eu Programming in Visual Basic 2010 OBJECTIVES: Chapter 2 User Interface Design Upon completion of this chapter, your students will be able to 1. Use text boxes, masked text boxes, rich text boxes, group boxes, check boxes, radio buttons,

More information

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING

Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Selection Control Structure CSC128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING MULTIPLE SELECTION To solve a problem that has several selection, use either of the following method: Multiple selection nested

More information

Visual Basic 2008 The programming part

Visual Basic 2008 The programming part Visual Basic 2008 The programming part Code Computer applications are built by giving instructions to the computer. In programming, the instructions are called statements, and all of the statements that

More information

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14

Chapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14 Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to

More information

Visual Basic 2008 Anne Boehm

Visual Basic 2008 Anne Boehm TRAINING & REFERENCE murach s Visual Basic 2008 Anne Boehm (Chapter 3) Thanks for downloading this chapter from Murach s Visual Basic 2008. We hope it will show you how easy it is to learn from any Murach

More information

Decision Structures. Start. Do I have a test in morning? Study for test. Watch TV tonight. Stop

Decision Structures. Start. Do I have a test in morning? Study for test. Watch TV tonight. Stop Decision Structures In the programs created thus far, Visual Basic reads and processes each of the procedure instructions in turn, one after the other. This is known as sequential processing or as the

More information

LECTURE 04 MAKING DECISIONS

LECTURE 04 MAKING DECISIONS PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 04 MAKING DECISIONS

More information

Making Decisions and Working with Strings

Making Decisions and Working with Strings GADDIS_CH04 12/16/08 6:47 PM Page 193 CHAPTER 4 Making Decisions and Working with Strings TOPICS 4.1 The Decision Structure 4.2 The If...Then Statement 4.3 The If...Then...Else Statement 4.4 The If...Then...ElseIf

More information

Software Design & Programming I

Software Design & Programming I Software Design & Programming I Starting Out with C++ (From Control Structures through Objects) 7th Edition Written by: Tony Gaddis Pearson - Addison Wesley ISBN: 13-978-0-132-57625-3 Chapter 4 Making

More information

Microsoft Visual Basic 2015: Reloaded

Microsoft Visual Basic 2015: Reloaded Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Three Memory Locations and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named constants

More information

variables programming statements

variables programming statements 1 VB PROGRAMMERS GUIDE LESSON 1 File: VbGuideL1.doc Date Started: May 24, 2002 Last Update: Dec 27, 2002 ISBN: 0-9730824-9-6 Version: 0.0 INTRODUCTION TO VB PROGRAMMING VB stands for Visual Basic. Visual

More information

You will have mastered the material in this chapter when you can:

You will have mastered the material in this chapter when you can: CHAPTER 6 Loop Structures OBJECTIVES You will have mastered the material in this chapter when you can: Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand

More information

Introduction to C Programming

Introduction to C Programming 1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print

More information

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate

More information

Microsoft Visual Basic 2015: Reloaded

Microsoft Visual Basic 2015: Reloaded Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Five More on the Selection Structure Objectives After studying this chapter, you should be able to: Determine whether a solution requires a nested

More information

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid: 1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

GSAK (Geocaching Swiss Army Knife) GEOCACHING SOFTWARE ADVANCED KLASS GSAK by C3GPS & Major134

GSAK (Geocaching Swiss Army Knife) GEOCACHING SOFTWARE ADVANCED KLASS GSAK by C3GPS & Major134 GSAK (Geocaching Swiss Army Knife) GEOCACHING SOFTWARE ADVANCED KLASS GSAK - 102 by C3GPS & Major134 Table of Contents About this Document... iii Class Materials... iv 1.0 Locations...1 1.1 Adding Locations...

More information

1. Managing Information in Table

1. Managing Information in Table 1. Managing Information in Table Spreadsheets are great for making lists (such as phone lists, client lists). The researchers discovered that not only was list management the number one spreadsheet activity,

More information

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events

1 Dept: CE.NET Programming ( ) Prof. Akash N. Siddhpura. Working with Form: properties, methods and events Working with Form: properties, methods and events To create a New Window Forms Application, Select File New Project. It will open one dialog box which is shown in Fig 2.1. Fig 2.1 The New Project dialog

More information

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,

More information

Visual BASIC Creating an Application. Choose File New Project from the menu

Visual BASIC Creating an Application. Choose File New Project from the menu Creating an Application Choose File New Project from the menu Choose Windows Application Name the project Copyright Project Place a check in the Create directory for solution box Click Browse Choose and/or

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Access Intermediate

Access Intermediate Access 2010 - Intermediate (103-134) Building Access Databases Notes Quick Links Building Databases Pages AC52 AC56 AC91 AC93 Building Access Tables Pages AC59 AC67 Field Types Pages AC54 AC56 AC267 AC270

More information

MICROSOFT EXCEL 2003 LEVEL 3

MICROSOFT EXCEL 2003 LEVEL 3 MICROSOFT EXCEL 2003 LEVEL 3 WWP Training Limited Page 1 STUDENT EDITION LESSON 1 - USING LOGICAL, LOOKUP AND ROUND FUNCTIONS... 7 Using Lookup Functions... 8 Using the VLOOKUP Function... 8 Using the

More information

Music and Videos. with Exception Handling

Music and Videos. with Exception Handling VISUAL BASIC LAB with Exception Handling Copyright 2015 Dan McElroy - Lab Assignment Develop a Visual Basic application program that is used to input the number of music songs and the number of videos

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode

More information

Microsoft Visual Basic 2012: Reloaded

Microsoft Visual Basic 2012: Reloaded Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter Five More on the Selection Structure Objectives After studying this chapter, you should be able to: Determine whether a solution requires a nested

More information

HOUR 4 Understanding Events

HOUR 4 Understanding Events HOUR 4 Understanding Events It s fairly easy to produce an attractive interface for an application using Visual Basic.NET s integrated design tools. You can create beautiful forms that have buttons to

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

St. Benedict s High School. Computing Science. Software Design & Development. (Part 1 Computer Programming) National 5

St. Benedict s High School. Computing Science. Software Design & Development. (Part 1 Computer Programming) National 5 Computing Science Software Design & Development (Part 1 Computer Programming) National 5 VARIABLES & DATA TYPES Variables provide temporary storage for information that will be needed while a program is

More information

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer

More information

ODBC Setup MS Access 2007 Overview Microsoft Access 2007 can be utilized to create ODBC connections. This page will show you the steps to create an

ODBC Setup MS Access 2007 Overview Microsoft Access 2007 can be utilized to create ODBC connections. This page will show you the steps to create an ODBC Setup MS Access 2007 Overview Microsoft Access 2007 can be utilized to create ODBC connections. This page will show you the steps to create an ODBC connection. 1. To open Access 2007, click Start

More information

conditional statements

conditional statements L E S S O N S E T 4 Conditional Statements PU RPOSE PROCE DU RE 1. To work with relational operators 2. To work with conditional statements 3. To learn and use nested if statements 4. To learn and use

More information

BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17)

BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17) BITG 1223: Selection Control Structure by: ZARITA (FTMK) LECTURE 4 (Sem 1, 16/17) 1 Learning Outcomes At the end of this lecture, you should be able to: 1. Explain the concept of selection control structure

More information

MICROSOFT EXCEL 2002 (XP): LEVEL 3

MICROSOFT EXCEL 2002 (XP): LEVEL 3 MICROSOFT EXCEL 2002 (XP): LEVEL 3 WWP Training Limited Page 1 STUDENT EDITION LESSON 1 - USING LOGICAL LOOKUP AND ROUND FUNCTIONS... 7 Using Lookup Functions... 8 Using the VLOOKUP Function... 8 Using

More information

IT3101 -Rapid Application Development Second Year- First Semester. Practical 01. Visual Basic.NET Environment.

IT3101 -Rapid Application Development Second Year- First Semester. Practical 01. Visual Basic.NET Environment. IT3101 -Rapid Application Development Second Year- First Semester Practical 01 Visual Basic.NET Environment. Main Area Menu bar Tool bar Run button Solution Explorer Toolbox Properties Window Q1) Creating

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

NOTES: Variables & Constants (module 10)

NOTES: Variables & Constants (module 10) Computer Science 110 NAME: NOTES: Variables & Constants (module 10) Introduction to Variables A variable is like a container. Like any other container, its purpose is to temporarily hold or store something.

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

CIS 3260 Intro. to Programming with C#

CIS 3260 Intro. to Programming with C# Running Your First Program in Visual C# 2008 McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Run Visual Studio Start a New Project Select File/New/Project Visual C# and Windows must

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

IF & VLOOKUP Function

IF & VLOOKUP Function IF & VLOOKUP Function If Function An If function is used to make logical comparisons between values, returning a value of either True or False. The if function will carry out a specific operation, based

More information

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials Fundamentals We build up instructions from three types of materials Constants Expressions Fundamentals Constants are just that, they are values that don t change as our macros are executing Fundamentals

More information

Wyo VB Lecture Notes - Objects, Methods, & Properties

Wyo VB Lecture Notes - Objects, Methods, & Properties Wyo VB Lecture Notes - Objects, Methods, & Properties Objective #1: Use forms appropriately. A form is a basic building block of a Visual Basic project. Eventually, you'll be creating projects that consist

More information

Task #1 The if Statement, Comparing Strings, and Flags

Task #1 The if Statement, Comparing Strings, and Flags Chapter 3 Lab Selection Control Structures Lab Objectives Be able to construct boolean expressions to evaluate a given condition Be able to compare Strings Be able to use a flag Be able to construct if

More information

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA DECISION STRUCTURES: USING IF STATEMENTS IN JAVA S o far all the programs we have created run straight through from start to finish, without making any decisions along the way. Many times, however, you

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Chapter 3 Lab Decision Structures

Chapter 3 Lab Decision Structures Chapter 3 Lab Decision Structures Lab Objectives Be able to construct boolean expressions to evaluate a given condition Be able to compare String objects Be able to use a flag Be able to construct if and

More information

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Basic Topics: Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Review ribbon terminology such as tabs, groups and commands Navigate a worksheet, workbook, and multiple workbooks Prepare

More information

A Second Visual BASIC Application : Greetings

A Second Visual BASIC Application : Greetings The Greetings Program A Second Visual BASIC Application : Greetings The following instructions take you through the steps to create a simple application. A greeting is displayed in one of four different

More information

Programming Language 2 (PL2)

Programming Language 2 (PL2) Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language

More information

Lab 4: Decisions and Boolean Logic This lab accompanies Chapter 4 of Starting Out with Programming Logic & Design.

Lab 4: Decisions and Boolean Logic This lab accompanies Chapter 4 of Starting Out with Programming Logic & Design. Starting Out with Programming Logic and Design 1 Lab 4: Decisions and Boolean Logic This lab accompanies Chapter 4 of Starting Out with Programming Logic & Design. Name: Lab 4.1 Logical Operators and Dual

More information

Software Development Techniques. December Sample Exam Marking Scheme

Software Development Techniques. December Sample Exam Marking Scheme Software Development Techniques December 2015 Sample Exam Marking Scheme This marking scheme has been prepared as a guide only to markers. This is not a set of model answers, or the exclusive answers to

More information

Project 3 Restaurant or Store

Project 3 Restaurant or Store HNHS Computer Programming I / IPFW CS 11400 Bower - Page 1 Project 3 Restaurant or Store HNHS Computer Programming I / IPFW CS 11400 Bower - Page 2 Description You will create a program that calculates

More information

Advanced Reporting Tool

Advanced Reporting Tool Advanced Reporting Tool The Advanced Reporting tool is designed to allow users to quickly and easily create new reports or modify existing reports for use in the Rewards system. The tool utilizes the Active

More information

Chapter 4 Lab. Loops and Files. Objectives. Introduction

Chapter 4 Lab. Loops and Files. Objectives. Introduction Chapter 4 Lab Loops and Files Objectives Be able to convert an algorithm using control structures into Java Be able to write a while loop Be able to write a do-while loop Be able to write a for loop Be

More information

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 4 Making Decisions In this chapter, you will learn about: Evaluating Boolean expressions to make comparisons The relational comparison operators

More information

Coaching Applicant Information

Coaching Applicant Information Coaching Applicant Information Welcome to the Boulder Valley School District s online application system. We are pleased about your interest in applying for employment with our school district. Our online

More information

Topics. Chapter 5. Equality Operators

Topics. Chapter 5. Equality Operators Topics Chapter 5 Flow of Control Part 1: Selection Forming Conditions if/ Statements Comparing Floating-Point Numbers Comparing Objects The equals Method String Comparison Methods The Conditional Operator

More information

Make View: Check Code

Make View: Check Code Lesson 2 Make View: Check Code SUMMARY This lesson is an introduction to creating Check Code inside the Make View module of Epi Info. In this lesson, you will learn how to customize your survey by creating

More information

Decision Structures. Lecture 3 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz

Decision Structures. Lecture 3 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Decision Structures Lecture 3 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Chapter Topics o Relational Operators o The if Statement o The if-else Statement o Nested if statements o The if-else-if

More information

ediningexpress Owners Manual User Guide Copyright All Rights Reserved.

ediningexpress Owners Manual User Guide Copyright All Rights Reserved. Owners Manual User Guide Copyright 2012. All Rights Reserved. Table of Contents Introduction... 1 Login... 2 Modify Button... 3 Control Panel... 4 Create New Menu... 6 Create Menu Sizes... 7 Create Available

More information

Stamina Software Pty Ltd. TRAINING MANUAL Viságe BIT VIEWER

Stamina Software Pty Ltd. TRAINING MANUAL Viságe BIT VIEWER Stamina Software Pty Ltd TRAINING MANUAL Viságe BIT VIEWER Version: 3 31 st October 2011 Viságe BIT Viewer TABLE OF CONTENTS VISÁGE BIT VIEWER... 2 ELEMENTS OF THE VISÁGE BIT VIEWER SCREEN... 3 TITLE...

More information

Lesson 04. Control Structures I : Decision Making. MIT 31043, VISUAL PROGRAMMING By: S. Sabraz Nawaz

Lesson 04. Control Structures I : Decision Making. MIT 31043, VISUAL PROGRAMMING By: S. Sabraz Nawaz Lesson 04 Control Structures I : Decision Making MIT 31043, VISUAL PROGRAMMING Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University of Sri Lanka Decision

More information

MICROSOFT WORD. Table of Contents. What is MSWord? Features LINC TWO

MICROSOFT WORD. Table of Contents. What is MSWord? Features LINC TWO Table of Contents What is MSWord? MS Word is a word-processing program that allows users to create, edit, and enhance text in a variety of formats. Word is a powerful word-processor with sophisticated

More information

MICROSOFT EXCEL VERSIONS 2007 & 2010 LEVEL 3. WWP Learning and Development Ltd Page 1

MICROSOFT EXCEL VERSIONS 2007 & 2010 LEVEL 3. WWP Learning and Development Ltd Page 1 MICROSOFT EXCEL VERSIONS 2007 & 2010 LEVEL 3 WWP Learning and Development Ltd Page 1 NOTE Unless otherwise stated, screenshots in this book were taken using Excel 2007 with a silver colour scheme and running

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Repe$$on CSC 121 Fall 2015 Howard Rosenthal

Repe$$on CSC 121 Fall 2015 Howard Rosenthal Repe$$on CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while

More information

Access Intermediate

Access Intermediate Access 2013 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC124 AC125 Selecting Fields Pages AC125 AC128 AC129 AC131 AC238 Sorting Results Pages AC131 AC136 Specifying Criteria Pages

More information

Repetition CSC 121 Fall 2014 Howard Rosenthal

Repetition CSC 121 Fall 2014 Howard Rosenthal Repetition CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Learn the following three repetition methods, their similarities and differences, and how to avoid common errors when using them: while do-while

More information

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators

Introduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program

More information

INSTALLATION AND USER S GUIDE OfficeCalendar for Microsoft Outlook

INSTALLATION AND USER S GUIDE OfficeCalendar for Microsoft Outlook INSTALLATION AND USER S GUIDE OfficeCalendar for Microsoft Outlook Sharing Microsoft Outlook Calendar and Contacts without Exchange Server Table of Contents What is OfficeCalendar? Sharing Microsoft Outlook

More information

Chapter11 practice file folder. For more information, see Download the practice files in this book s Introduction.

Chapter11 practice file folder. For more information, see Download the practice files in this book s Introduction. Make databases user friendly 11 IN THIS CHAPTER, YOU WILL LEARN HOW TO Design navigation forms. Create custom categories. Control which features are available. A Microsoft Access 2013 database can be a

More information

EXCEL 2003 DISCLAIMER:

EXCEL 2003 DISCLAIMER: EXCEL 2003 DISCLAIMER: This reference guide is meant for experienced Microsoft Excel users. It provides a list of quick tips and shortcuts for familiar features. This guide does NOT replace training or

More information

Repe$$on CSC 121 Spring 2017 Howard Rosenthal

Repe$$on CSC 121 Spring 2017 Howard Rosenthal Repe$$on CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Learn the following three repetition structures in Java, their syntax, their similarities and differences, and how to avoid common errors when

More information

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition Objectives Programming Logic and Design Sixth Edition Chapter 6 Arrays In this chapter, you will learn about: Arrays and how they occupy computer memory Manipulating an array to replace nested decisions

More information

Part II Composition of Functions

Part II Composition of Functions Part II Composition of Functions The big idea in this part of the book is deceptively simple. It s that we can take the value returned by one function and use it as an argument to another function. By

More information

1 Information system An information system is the combination of technology(computers) and people that enable an organization to collect data, store them, and transform them into information Data Data

More information

Microsoft Access XP (2002) - Advanced Queries

Microsoft Access XP (2002) - Advanced Queries Microsoft Access XP (2002) - Advanced Queries Group/Summary Operations Change Join Properties Not Equal Query Parameter Queries Working with Text IIF Queries Expression Builder Backing up Tables Action

More information

Decision Structures. Lesson 03 MIT 11053, Fundamentals of Programming

Decision Structures. Lesson 03 MIT 11053, Fundamentals of Programming Decision Structures Lesson 03 MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz M.Sc. in IS (SLIIT), PGD in IS (SLIIT), BBA (Hons.) Spl. In IS (SEUSL), MIEEE, Microsoft Certified Professional

More information

Module 9: Validating User Input

Module 9: Validating User Input Module 9: Validating User Input Table of Contents Module Overview 9-1 Lesson 1: Restricting User Input 9-2 Lesson 2: Implementing Field-Level Validation 9-8 Lesson 3: Implementing Form-Level Validation

More information

Recommended GUI Design Standards

Recommended GUI Design Standards Recommended GUI Design Standards Page 1 Layout and Organization of Your User Interface Organize the user interface so that the information follows either vertically or horizontally, with the most important

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e Before writing a program to solve a particular problem, it s essential to have a thorough understanding of the problem and a carefully planned approach to solving the problem. The

More information

Design Of Human Computer Interfaces Assignment 1- Hello World. Compliance Report

Design Of Human Computer Interfaces Assignment 1- Hello World. Compliance Report Design Of Human Computer Interfaces Assignment 1- Hello World Compliance Report Prepared for: Skip Poehlman Prepared By: K C Course: SE 4D03 Date: September 30, 2008 Contents 1. Code Listing a. Module

More information

LOOPS. Repetition using the while statement

LOOPS. Repetition using the while statement 1 LOOPS Loops are an extremely useful feature in any programming language. They allow you to direct the computer to execute certain statements more than once. In Python, there are two kinds of loops: while

More information

Starting the Import From the Start menu, select the [Import Questions] task. A window will appear:

Starting the Import From the Start menu, select the [Import Questions] task. A window will appear: Importing Questions to Respondus Respondus allows you to import multiple choice, true-false, essay, fill in the blank, matching and multiple answer questions from a file. The questions must be organized

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

DEVELOPING OBJECT ORIENTED APPLICATIONS

DEVELOPING OBJECT ORIENTED APPLICATIONS DEVELOPING OBJECT ORIENTED APPLICATIONS By now, everybody should be comfortable using form controls, their properties, along with methods and events of the form class. In this unit, we discuss creating

More information

Decision Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Decision Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan Decision Control Structure DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) Decision control

More information