Solved

Suppose You Would Like Your Code to Perform Several Tasks

Question 2

Multiple Choice

Suppose you would like your code to perform several tasks: Use a For…Next loop with an InputBox to prompt the user four times for the price of four different T-shirts, then display each shirt price with a 25% discount in the ListBox lstResult. Which of the following code segments correctly performs these tasks?


A) Dim intIndex As Integer
Dim sngPrice, sngDiscountPrice As Single

For intIndex = 1 To 4
SngPrice = CSng(InputBox("Enter price of shirt " & intIndex.ToString) )
SngDiscountPrice = sngPrice * 0.75
LstResult.Items.Add(sngDiscountPrice)
Next
B) Dim intIndex As Integer
Dim sngPrice, sngDiscountPrice As Single

For intIndex = 0 To 4
SngPrice = CSng(InputBox("Enter price of shirt " & intIndex.ToString) )
SngDiscountPrice = sngPrice - (.75 * sngPrice)
Next
LstResult.Items.Add(sngDiscountPrice)
C) Dim intIndex As Integer
Dim sngPrice, sngDiscountPrice As Single

For intIndex = 1 To 4
SngPrice = CSng(InputBox("Enter price of shirt " & intIndex.ToString) )
SngDiscountPrice = sngPrice * (.25 - sngPrice)
LstResult.Items.Add(sngDiscountPrice)
Next
D) Dim intIndex As Integer
Dim sngPrice, sngDiscountPrice As Single

For intIndex = 0 To 4
SngPrice = CSng(InputBox("Enter price of shirt " & intIndex.ToString) )
SngDiscountPrice = sngPrice * 0.25
LstResult.Items.Add(intIndex & " " & sngDiscountPrice)
Next

Correct Answer:

verifed

Verified

Related Questions