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

Visual Basics: 1 ) Write an if/else statement that compares the double variable

ID: 3805280 • Letter: V

Question

Visual Basics: 1 ) Write an if/else statement that compares the double variable  pH with 7.0 and makes the following assignments to the bool variables neutral, base, and acid:

false, false, true if pH is less than 7

false, true, false if pH is greater than 7

true, false, false if pH is equal to 7

2) Visual Basics: Write an if/else statement that adds 1 to the variable  minors if the variable  age is less than 18, adds 1 to the variable  adults if age is 18 through 64, and adds 1 to the variable  seniors if age is 65 or older.

Explanation / Answer

Question 1

Answer:

Module VBModule

Sub Main()
Dim PH as Integer
Dim neutral, base, acid as Boolean
If PH < 7 Then
neutral = false
base = false
acid = true
ElseIf PH > 7 Then
neutral = false
base = true
acid = false
Else
neutral = true
base = false
acid = false
End If

End Sub
  
End Module

Question 2

Answer:

Module VBModule

Sub Main()
Dim age , minosr, adults, seniors as Integer
  
If age < 18 Then
minosr = minosr + 1
ElseIf age >= 18 and age < 65 Then
adults = adults + 1
Else
seniors = seniors + 1
End If

End Sub
  
End Module