Concept explainers
Open the Calories Solution.sln file contained in the VB2017\Chap08\Calories Solution folder. Open the Code Editor window and locate the btnDisplay_Click procedure. The procedure declares and initializes a one-dimensional array named intCalories. The array stores the numbers of daily calories consumed. The procedure should calculate and display the average number of calories consumed; use the Math.Round method to round the average to an integer. (You learned about the Math.Round method in Chapter 6.) The procedure should also display the number of days in which the daily calories were greater than the average, the number of days in which the daily calories were the same as the average, and the number of days in which the daily calories were less than the average. Code the procedure. Save the solution and then start and test the application.
Trending nowThis is a popular solution!
Chapter 8 Solutions
EBK 3N3-EBK: PROGRAMMING W/MICROSOFT VI
- If the intNums array contains six elements, which of the following statements assigns the number 6 to the intElements variable? intElements = Len(intNums) intElements = Length(intNums) intElements = intNums.Len intElements = intNums.Lengtharrow_forwardThe dblNums array is a six-element Double array. Which of the following If clauses determines whether the entire array has been searched? a. If intSub = dblNums.Length Then b. If intSub <= dblNums.Length Then c. If intSub > dblNums.GetUpperBound(0) Then d. Both a and c.arrow_forwardWrite a statement that assigns the highest column subscript in the intOrders array to the intLastColSub variable.arrow_forward
- The intNums array is declared as follows: Dim intNums() As Integer = {10, 5, 7, 2}. Which of the following blocks of code correctly calculates the average value stored in the array? The intTotal, intSub, and dblAvg variables contain the number 0 before the loop is processed. a. Do While intSub < 4 intNums(intSub) = intTotal + intTotal intSub += 1 Loop dblAvg = intTotal / intSub b. Do While intSub < 4 intTotal += intNums(intSub) intSub = intSub + 1 Loop dblAvg = intTotal / intSub c. Do While intSub < 4 intTotal += intNums(intSub) intSub += 1 Loop dblAvg = intTotal / intSub – 1 d. Do While intSub < 4 intTotal = intTotal + intNums(intSub) intSub = intSub + 1 Loop dblAvg = intTotal / (intSub – 1)arrow_forwardThe intSales array is declared as follows: Dim intSales() As Integer = {10000, 12000, 900, 500, 20000}. Which of the following loops will correctly multiply each element by 2? The intSub variable contains the number 0 before the loop is processed. a. Do While intSub <= 4 intSub *= 2 Loop b. Do While intSub <= 4 intSales *= 2 intSub += 1 Loop c. Do While intSub < 5 intSales(intSub) *= 2 intSub += 1 Loop d. None of the above.arrow_forwardThe strCities array is declared using the Dim strCities(10) As String statement.The intSub variable keeps track of the array subscripts and is initialized to 0. Which of the following Do clauses tells the computer to process the loop instructions for each element in the array?a. Do While intSub < strCities.Lengthb. Do While intSub <= strCities.Length – 1c. Do Until intSub = strCities.Lengthd. all of the abovearrow_forward
- An array is declared using the statement Dim inventory(4) As Product. Which of the following statements assigns the number 100 to the intQuantity member variable contained in the last array element? inventory(3).intQuantity = 100 inventory(4).Product.intQuantity = 100inventory(4).intQuantity=100inventory.intQuantity(4) = 100arrow_forwardWhich of the following displays the number of elements contained in theintItems array?a. lblCount.Text = intItems.Lenb. lblCount.Text = intItems.Lengthc. lblCount.Text = Length(intItems)d. lblCount.Text = intItems.NumElementsarrow_forwardIn order to access each element in an array, the For...Next statement needs to know the highest subscript in the array. True or False?arrow_forward
- Question Completion Status: a) Mowngto anotner question wal save this response. Question 7 $$ \left(\begin{array}{cccc} -5 & 3 & 1 & 10 \\ 5 & 5 & 4 & 6 \\ 4 & -2 & 0 & -5 \end{array}\right) $$ TTI Aruil $\mathrm{- o phe -a -}$ mouter SP.VS.049|arrow_forwardWrite a statement that assigns the number 7 to the element located in the third row, first column in the intQuantities array.arrow_forwardThe decSales array is declared using the Dim decSales(4) As Decimal statement. Which of the following If clauses can be used to validate the array subscript stored in the intX variable?a. If decSales(intX) >= 0 AndAlso decSales(intX) < 4 Thenb. If decSales(intX) >= 0 AndAlso decSales(intX) <= 4 Thenc. If intX >= 0 AndAlso intX <= 4 Thend. If intX >= 0 AndAlso intX < 4 Thenarrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT