Exercises
Exercises
In Exercises 1 through 6 , determine the output displayed in the text box or list box by the lines of code.
6. Dim m As Integer = 4
Dim n As Integer = 3
Dim s As String = "Microsoft"
Dim t As String = "soft"
lstOutput.Items.Add(s.Length)
lstOutput.Items.Add(s.ToLower)
lstOutput.Items.Add(s.Substring(m, n − 1))
lstOutput.Items.Add(s.IndexOf(t))
12. PRICE OF KETCHUP The following steps compute the price of ketchup:
a. Declare the variable item as type String. Declare the
variables regularPrice and discount as type Decimal.
b. Assign “ketchup” to the variable item.
c. Assign 1.80 to the variable regularPrice.
d. Assign .27 to the variable discount.
e. Assign to the variable discountPrice the expression
(NOTE: The product is 1.53.)
f. Display the sentence “1.53 is the sale price of ketchup.”
13. DISTANCE FROM A STORM If is the number of seconds between lightning and thunder, the storm is /5
miles away.
Write a program that reads the number of seconds between lightning and thunder and reports the distance of the
storm rounded to two decimal places.