Question

This is Visual Basics... Write an if/else statement that assigns true to the variable fever if...

This is Visual Basics...

Write an if/else statement that assigns true to the variable fever if the variable temperature is greater than 98.6; otherwise it assigns false to fever.*

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.*

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The Visual basic for the given scenario is given below. Both the scenario are included in the same code-

Sub temp()
Dim temp ' Declaring variables
Dim fever
Dim age
Dim minors
Dim adults
Dim senior
minor = 2
adults = 5
senior = 2
temp = InputBox("Enter temperature") ' Getting temp input from user
If temp > 98.6 Then 'Checking the condition in if else
fever = True 'Assigning true if condition is true
Else
fever = False ' Assigning false if condition is false
End If
MsgBox ("Is fever: " & fever) ' Displaying the result
age = InputBox("Enter Age") ' Getting age from the user
If age < 18 Then 'Checking the condition
minor = minor + 1 'Incrementing minor
ElseIf age > 18 And age < 64 Then 'Checking another condition
adults = adults + 1 'Incrementing adult
Else
senior = senior + 1 ' Incrementing senior
End If
'Displaying the result
MsgBox ("Minor = " & minor & " Adult =" & adults & " Senior = " & senior)

End Sub

Code screenshot

Sub temp () Dim temp Declaring variables Dim fever Dim age Dim minors Dim adults Dim senior minor = 2 adults = 5 senior-2 temOutput

Microsoft Excel Enter temperature OK Cancel 98 盤!)

Microsoft Excel X Is fever: True OK

Add a comment
Know the answer?
Add Answer to:
This is Visual Basics... Write an if/else statement that assigns true to the variable fever if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT