A+ Guide to Hardware Edition 6th

Topics: Coca-Cola, C, Programming language Pages: 5 (357 words) Published: August 20, 2014
Week 9 and 10
1. Decision making (Selection Structure)
2. Often used comparison operators: (pp. 199-200)

3. If statements: single-alternative, dual-alternative, and multiple-alternative. (192-198, 276-278) a. If / End If statement
If [evaluating a condition] Then
[Some code are executed if True]
End If
b. If / Else /End If statement
If [evaluating a condition] Then
[Some code are executed if True]
Else
[Other code are executed if False]
End If

c. If / ElseIf .. /End If statement (When you have more than two selections, pp. 275-278.) If [evaluating a condition] Then
[Some code are executed]
ElseIf [evaluating second condition] Then
[Other code are executed. You may have as many ElseIf sections as you need. ] Else
[Other code are executed]
End If

4. TryParse function (128-129, 219-220): Integer.TryParse, Single.TryParse, Long.TryParse and other types of TryParse function. This function requires two arguments, a string and a numeric variable. It does two things: A. It returns a Boolean value, depending on whether it succeeds in converting a string to a numeric value. B. It assigns a value to its second argument, either a converted numeric value or, in not convertible, zero.

Understand why TryParse function is more useful than Val () function Here is an example where TryParse Function is used to verify user entry. If Double.TryParse(txtSales.Text, dblSale) Then

(Some code here………)
Else
MessageBox.Show("Wrong sales amount. Try again.") End If

5. ToUpper and ToLower methods (215-218)
Projects: SelectionIf
GUI (when debugging)

Project Selection Code:

Code for btnTryParse

Code btnDriverLicense

Assignment 1: Ticket Price.
Pseudo code for btnTicket:
Ask user to type S, C or other letter for a senior, a child, or anyone else; If senior, ask to pay $5; if child, free; other people, $10

Assignment 2: Vending machine
Pseudo code for btnVendingMachine
Ask user to type a number:
10 for Pepsi; 15 for Coca Cola; 18 for Snapple; 22 for Ginger Ale; 30 for Gatorade If user types 10, txtDisplay will show “You got a Pepsi!” ……. If user types a wrong number, txtDisplay will show “ …. does not exist. Try again.” Tip:

1. Treat numbers as strings in this project because they are not used for calculation. 2. No need to use ToUpper or ToLower method because numeric strings don’t have case.
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Apa Manual 6th Edition Essay
  • Hardware Essay
  • hardware Essay
  • Hardware Essay
  • A+ Guide to Hardware Chapter 10 Answers Essay
  • APA Manual 6th Edition Essay
  • Apa Refrence 6th Edition Essay
  • APA 6th Edition Template without Abstract Essay

Become a StudyMode Member

Sign Up - It's Free