Question: Program Analysis 1. What will occur when the user taps or clicks the btnSlope Button in the following code? Private Sub btnSlope_Click(ByVal sender As System.Object,
Program Analysis
1. What will occur when the user taps or clicks the btnSlope Button in the following code? Private Sub btnSlope_Click(ByVal sender As System.Object, ByVal e As System. EventArgs) Handles btnSlope.Click Dim decRise As Decimal Dim decRun As Decimal Dim decSlope As Decimal decRise = 12.3D decRun = 2.1D decSlope = decRise / decRun lblSlope.Text = The Line Slope is & decSlope.ToString(F3) End Sub
2. How would the number .0256 be displayed if the format specifier (P) is used in a Convert.ToString statement?
3. How would the number 3746.35555 be displayed if the format specifier (F3) is used in a Convert.ToString statement?
4. If you want the user to enter her telephone number with the area code, which .NET component would be best to use on the Windows Form object?
5. Using the format specifier with the ToString procedure, write the statement that would display: a. The value in the decDvdCost variable with a dollar sign and two places to the right of the decimal point in a label named lblDvd b. The value in the decWithholdingTaxRate variable with a percent sign and one place to the right of the decimal point in a label named lblWithholdingTaxRate c. The value in the decOilRevenue variable with commas as needed, two places to the right of the decimal point, and no dollar sign in a label called lblOilRevenue
6. Write a single line of code to declare a variable decWindSpeed as a Decimal data type and assign it the value 25.47. Use a forced literal to ensure that the compiler views this number as a Decimal data type.
7. What would the values of these variables be at the end of the code that follows? a. intParts b. intBoxes c. intLeftovers Dim intParts As Integer Dim intBoxes As Integer Dim intLeftovers As Integer intParts = 77 intPartsPerBox = 9 intBoxes = intParts \ intPartsPerBox intLeftovers = intParts Mod intBoxes
8. Are the following statements written correctly? If not, how should they be written? Dim dblPay as Double lblPay.Text = dblPay.ToString(C2)
9. For a Button object named btnCalories, write the tap or click event handler to implement the following requirements and calculate the number of calories burned during a run: a. Declare variables named strMilesRan, decCaloriesConsumed, and decMilesRan. b. Declare a constant named cdecCaloriesBurnedPerHour and assign it the value 700. (Assume you burn 700 calories for every mile you run.) c. Allow the user to enter the number of miles she ran today. d. Convert the number of miles to a Decimal data type. e. Calculate the number of calories the user burned during her run. f Display the result rounded to zero decimal places in a label named lblCaloriesBurned.
10. What would the output be when the user taps or clicks the btnDrivingAge Button? Private Sub btnDrivingAge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDrivingAge.Click Dim intPresentAge As Integer Const cintDrivingAge As Integer = 16 Dim intYearsToDrive As Integer intPresentAge = 13 intYearsToDrive = cintDrivingAge - intPresentAge lblYearsLeft.Text = intYearsToDrive.ToString() & year(s) until you can drive. End Sub
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
