Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the following group of questions, this is part of a set: Book:

ID: 3773478 • Letter: I

Question

I need help with the following group of questions, this is part of a set:

Book: Microsoft Visual Basic 2012 (8th Edition)

Chapter 6 Knowledge Check.

3) Write For...Next loops that calculate the sum of the following ranges and assign their sum to a variable named intSum:

A. The first 100 numbers starting with 1

B. The even numbers beginning at 10 and ending with 50

C. The numbers 20, 30, 40, 50, and 60

12) Write a bottom-controlled Do While loop with an empty body that continues while the user enters "Yes" into the strContinue variable.

13) Write a Do While loop to validate that the user enters a nonzero integer into an input box for a variable named intDenominator.

Explanation / Answer

3) Write For...Next loops that calculate the sum of the following ranges and assign their sum to a variable named intSum:

A. The first 100 numbers starting with 1

Dim intSum as Integer = 0
For index As Integer = 1 To 100
intSum += index
Next
Console.WriteLine(intSum)

B. The even numbers beginning at 10 and ending with 50

For index As Integer = 10 To 50 Step 2
intSum += index
Next
Console.WriteLine(intSum)

C. The numbers 20, 30, 40, 50, and 60

For index As Integer = 20 To 60 Step 10
intSum += index
Next
Console.WriteLine(intSum)

12) Write a bottom-controlled Do While loop with an empty body that continues while the user enters "Yes" into the strContinue variable.

Dim strContinue as String
Do
strContinue = Console.ReadLine()
Loop Until String.Compare(strContinue, "Yes", False)

13) Write a Do While loop to validate that the user enters a nonzero integer into an input box for a variable named intDenominator.

Dim intDenominator as Integer
Do While intDenominator = 0
intDenominator = Console.ReadLine()
Loop