
Amy M. answered 03/22/15
Tutor
5.0
(1,582)
CalTech Grad, Software engineer with 30+ years experience.
Write ONE Dim statement that declares a string variable fisrtName with initial value "Davis" and a double variable Score with initial value 99 (ONE statement).
Dim firstName As String = "Davis", Score As Double = 99
1) Dim x, y As Double = 5.0
Can an not initialize with multiple variables declared as same type. You could do
Dim x As Double = 5.0, y As Double = 5.0
2) Dim hyp, a, b As Double 'Compute hypotenus using Pythagorean Theorem
a = 4.0
b = 3.0
hyp ^ 2 = a ^ 2 + b ^ 2
a = 4.0
b = 3.0
hyp ^ 2 = a ^ 2 + b ^ 2
The = is an assignment (not equal) so on the right hand side it makes no sense to have the power operator
Dim hypsqr, a, b As Double 'Compute hypotenus using Pythagorean Theorem
a = 4.0
b = 3.0
hypsqr = a ^ 2 + b ^ 2
a = 4.0
b = 3.0
hypsqr = a ^ 2 + b ^ 2
before taking the squareroot, sqr() check that hypsqr is greater or equal to zero.
3) 'Change the caption of the form
frmMidterm.Text = "Project Done"
frmMidterm.Text = "Project Done"
shouldn it be
frmMidterm.Caption = "Project Done"
????
4)
If (-1.0 < dist < 1.0) Then
txtOutput.Text = "Inside
txtOutput.Text = "Inside
Maybe should be
If -1.0 < dist And dist < 1.0 Then
5)???????
6) Dim age As Integer
age = CInt(InputBox("Enter your age"))
If age > 65 Then
txtOutput.Text = "Senior"
Else If age > 12 Then
txtOutput.Text = "Adult"
Else
txtOutput.Text = "Children”
End If
age = CInt(InputBox("Enter your age"))
If age > 65 Then
txtOutput.Text = "Senior"
Else If age > 12 Then
txtOutput.Text = "Adult"
Else
txtOutput.Text = "Children”
End If
this is two nested if statements but only one end if. I think changing the second if to an else if will make the code compile.
7) Dim str as String = InputBox("What's your favorite sports?")
Select Case str
Case "Basketball"
txtOutput.Text = "Basketball"
Case Else
txtOutput.Text = "Hate Sports"
End Select
Select Case str
Case "Basketball"
txtOutput.Text = "Basketball"
Case Else
txtOutput.Text = "Hate Sports"
End Select
change otherwise to else
change first case deleted the ls=
??????