Review Questions CHAPTER 3
1. Assume a procedure needs to store an item’s name and its price. The price may have a decimal place. Write the appropriate Dim statements to create the necessary procedure-level variables.
**Dim itemName As String
Dim priceName As Decimal
2. Assume a procedure needs to store the name of an item in inventory and its height and weight. The height may have decimal places; the weight will be whole numbers only. Write the appropriate Dim statements to create the necessary procedure-level variables.
***Dim ItemHeight As Decimal
Dim ItemWeight As Integer
3. Write an assignment statement that assigns Miami to an existing String variable named city.
*** Dim city As String
city = “Miami”
4. Write an assignment statement that adds the contents of the sales1 variable to the contents of sales2 variable, and then assigns the sum to an existing variable named totalSales. All of the variables have the Decimal date type.
***Dim totalSales As Decimal
Dim sales1 As Decimal
Dim sales2 As Decimal
totalSales = (sales1 + sales2)
5. Write an assignment statement that multiplies the contents of the salary variable by the number 1.5, and then assigns the results to the salary variable. The salary variable has the Decimal data type.
***Dim Salary As Decimal
Salary = 1.5D
6. Assume a form contains two buttons named salaryButton and bonusButton. Both buttons’ Click event procedures need to use the same variable, which is a String variable named employeeName. Write an appropriate statement to declare the employeeName variable. Also specify where you will need to enter the statement and whether the variable is a procedure-level or module-level variable.
*** Dim employeeName As String
9. Write the statement to convert the contents of the unitsTextBox to an integer. Store the Integer is an Integer Variable named numberofunits. Use isConverted as the name of the Boolean.
***Dim numberofunits As Integer
Dim isConverted As Boolean
isConverted = Integer.TryParse(unitsTextBox.Text, numberofunits)
15. What is a static variable?
***A special type of produce-level variable that retains its value even when the procedure ends.
Review Questions CHAPTER 4
7. Write an If...Then...Else statement that displays the string "Pontiac" in the carmakerLabel when the carTextBox contains the string "Grand Am".
***If carTextBox.text = "Grand Am"
ThencarMakeLabel.text = "Pontiac"End If
8.
***If variable < 0
ThenMessageBox.Show("Entry Error", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseMessageBox.Show("Valid Number", "Valid Number", MessageBoxButtons.OK, MessageBoxIcon.Information)End If9)
If quantity < 10
thenMessageBox.Show("Reorder", "Reorder", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseMessageBox.Show("OK", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
13) If hours are less than or equal to 40 then multiply hours by hoursRate. Else, subtract forty, multiple the remainder by hoursRate and 1.5. Add 40 time by hourRate.
***If hours < 40
Thengross = hours*hourRate
Elsegross = (hours - 40) * hourRate * 1.5 + 40 * hourRate
End If
Thursday, February 26, 2009
Tuesday, February 24, 2009
Questions
- 1. B. sales > 500D OrElse <800d
- 2. C. firstNameTextBox.Text.ToUpper( ) = “BOB”
- 3. B False
- 4. A true
- 5. B false
- 6. C Paul
- 7. B Jerry
- 8. C Paul
- 9. D. sue
- 10. A. only the true path
- 11. B Case 3, 512. C Paul
- 13. C Paul14. B Jerry
- 15. A Advance.NewLine
- 16. D String.IsNullOrEmpety(cityname)
- 17. C MessageBox.OK
- 18. B randomGenerator.Next(10,55)
- 19. C addressLabel.Text = city & “,” & state
- 20. B Case 1, 2, 3, 4, And 5
Thursday, February 5, 2009
Chapter 3 notes
Boolean Variable: A variable that can be changed between true and false, true or false
String: A series of characters that do not have numberical data but are a value, "I'm smarrttt!"
Method: The operations that an object is capable of performing,
import System.Globalization: Contains definitions for numberStyles and NumberFormatInfo, age = 35s
Operators: mathmatical symbols used in calculations, +-*/
Procedure Scope: The scope of the use of the variable in the procedure,Button click is event procedure.
Block scope: The scope of block-level variables, which can be used only within the statement block in which they are declared, If...Then....Else
Option Strict: strings will not be implicity converted to numbers, and vice versa, narrower data types will be promoted to wider data types, wider data types will not be demoted to narrower.
Focus Method: Used to move the focus to a control while an application is running, sending the focus to the name text box.
Identifier: The name of an object, nameTextBoxLiteral
Constant: An item of data whose value does not change while an application is running, tax rate.
TryParse Method: Used to convert a string to a number. 4 to int 4.
Convert Class: This class contains methods that return the result of converting a value to a specified data type, float to int.
Scope: Indicates where a variable can be used in the application's code, int.money can not be used in order form section.
Comments: Used to document a program internally; created using the apostrophe. 'Read this comment.
Static Variable: a procedure level variable that retains its value when the procedure ends, cost remains the same through out.
Pseudocode: Uses prhases to describe the steps a procedure needs to take to accomplish its goal, Set cost to 4 and then multiple it by 2.
Format Specifier: Determines the special characters that will appear in a formatted number, float to int removes the decimals.
DIM: A method to declare a variable in Visual Basic. Ex. Dim incomeValueLiteral Type
Character: a character used to convert a literal constant to data type.
Line Continuation Character: An underscore, which must be preceded by a space; used to break up a long instruction into two or more physical lines in the Code Editor window.
Precedence Numbers: Indicate the order in which the computer performs an operation (such as an arithmetic operation) in an expression.
Lifetime: Indicates how long a variable remains in the computer in the computer’s internal memory.
Module Scope: Refers to the scope of a module-level variable, which can be used by all of the procedures in the current form.Option Explicit: Disables implicit declaration of variables.
Empty String: A set of quotation marks with nothing between them. ""
Questions:
How do you name a variable and provide one example.
-You can name it in a way that it doesn’t conflict with other commands. (no spaces or special characters) EX: yellowBoards
How do you declare a variable and provide one example.
-You can declare a variable by using the DIM command. EX: Dim yellowBoards As Integer
What is the difference between DIM and Const?
-Dim is a variable that can be changed, while Const is a variable that is only named once and it stays the same. EX: Const TaxtRate As Decimal = 0.06D
How do you include a mathematical expression in assignment statements?
-you use variables. totalSkate= yellowBoards + blueBoards
How do you clear the text property when application is running?
-you use the clear function. yellowTextBox.Clear()
How do you format a number for output as a string?
-You use the convert.Tostring function. EX: totalBoardsLabel.Text = Convert.ToString(totalSkateBoards)
String: A series of characters that do not have numberical data but are a value, "I'm smarrttt!"
Method: The operations that an object is capable of performing,
import System.Globalization: Contains definitions for numberStyles and NumberFormatInfo, age = 35s
Operators: mathmatical symbols used in calculations, +-*/
Procedure Scope: The scope of the use of the variable in the procedure,Button click is event procedure.
Block scope: The scope of block-level variables, which can be used only within the statement block in which they are declared, If...Then....Else
Option Strict: strings will not be implicity converted to numbers, and vice versa, narrower data types will be promoted to wider data types, wider data types will not be demoted to narrower.
Focus Method: Used to move the focus to a control while an application is running, sending the focus to the name text box.
Identifier: The name of an object, nameTextBoxLiteral
Constant: An item of data whose value does not change while an application is running, tax rate.
TryParse Method: Used to convert a string to a number. 4 to int 4.
Convert Class: This class contains methods that return the result of converting a value to a specified data type, float to int.
Scope: Indicates where a variable can be used in the application's code, int.money can not be used in order form section.
Comments: Used to document a program internally; created using the apostrophe. 'Read this comment.
Static Variable: a procedure level variable that retains its value when the procedure ends, cost remains the same through out.
Pseudocode: Uses prhases to describe the steps a procedure needs to take to accomplish its goal, Set cost to 4 and then multiple it by 2.
Format Specifier: Determines the special characters that will appear in a formatted number, float to int removes the decimals.
DIM: A method to declare a variable in Visual Basic. Ex. Dim incomeValueLiteral Type
Character: a character used to convert a literal constant to data type.
Line Continuation Character: An underscore, which must be preceded by a space; used to break up a long instruction into two or more physical lines in the Code Editor window.
Precedence Numbers: Indicate the order in which the computer performs an operation (such as an arithmetic operation) in an expression.
Lifetime: Indicates how long a variable remains in the computer in the computer’s internal memory.
Module Scope: Refers to the scope of a module-level variable, which can be used by all of the procedures in the current form.Option Explicit: Disables implicit declaration of variables.
Empty String: A set of quotation marks with nothing between them. ""
Questions:
How do you name a variable and provide one example.
-You can name it in a way that it doesn’t conflict with other commands. (no spaces or special characters) EX: yellowBoards
How do you declare a variable and provide one example.
-You can declare a variable by using the DIM command. EX: Dim yellowBoards As Integer
What is the difference between DIM and Const?
-Dim is a variable that can be changed, while Const is a variable that is only named once and it stays the same. EX: Const TaxtRate As Decimal = 0.06D
How do you include a mathematical expression in assignment statements?
-you use variables. totalSkate= yellowBoards + blueBoards
How do you clear the text property when application is running?
-you use the clear function. yellowTextBox.Clear()
How do you format a number for output as a string?
-You use the convert.Tostring function. EX: totalBoardsLabel.Text = Convert.ToString(totalSkateBoards)
Subscribe to:
Posts (Atom)