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

Visual Basic Programming Hello everyone, I was wondering if you guys can help me

ID: 3891152 • Letter: V

Question

Visual Basic Programming

Hello everyone, I was wondering if you guys can help me with my homewok. I need to answer one of the following from the list. If you can select one or more from the list so that I can use. Thank you for you time.

Discussion 4

To earn points answer one question from below (those marked with * may have more than one unique answer) in the order the questions are shown. Please copy the question itself before stating your answer. If question 1 is answered then you must answer question 2, and so on.

1. Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true.*

2. Write an expression that evaluates to true if and only if the integer x is greater than the integer y.*

3. Write a conditional statement that assigns the boolean value true to the variable fever if the variable temperature is greater than 98.6.

4. Write a conditional statement that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000.

5. Write a conditional statement that decreases the variable shelfLife by 4 if the variable outsideTemperature is greater than 90.

6. Write a conditional statement that multiplies the value of the variable pay by one-and-a-half if the value of the boolean variable workedOvertime is true.

7. Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise.

8. Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison assigns salesTrend the value -1 (soldYesterday greater than soldToday) or 1.

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

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

11. Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the integer variables neutral, base, and acid:

0,0,1 if pH is less than 7
0,1,0 if pH is greater than 7
1,0,0 if pH is equal to 7

12. Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

13. Write code that displays the message "equal" if two integer variables a and b are more than zero and equal to each other, otherwise if both variables are more than zero display "positive", otherwise display "opposites" if only one variable is more than zero.

14. Write code that displays the message "opposites" if only one of two integer variables, a and b is more than zero.*

15. Write code that displays "No Success" if a boolean variable x is not True. *

16. Write code that demonstartes how to declare a boolean variable, then assign it to a boolean expression. Add a a one line comment to explain what the code is doing. *

17. Explain the difference between:
textbox1.text & textbox2.text and
textbox1.text+textbox2.text
use an example.

Explanation / Answer

1. Write an expression that evaluates to true if and only if the value of the boolean variable workedOvertime is true.

workedOvertime == true

2. Write an expression that evaluates to true if and only if the integer x is greater than the integer y.

x > y

3. Write a conditional statement that assigns the boolean value true to the variable fever if the variable temperature is greater than 98.6.

If temperature > 98.6 Then
fever = True
End If

4. Write a conditional statement that assigns 10,000 to the variable bonus if the value of the variable goodsSold is greater than 500,000.

If goodsSold > 500000 Then
bonus = 10000
End If

5. Write a conditional statement that decreases the variable shelfLife by 4 if the variable outsideTemperature is greater than 90.

If outsideTemperature > 90 Then
shelfLife = shelfLife - 4
End If

6. Write a conditional statement that multiplies the value of the variable pay by one-and-a-half if the value of the boolean variable workedOvertime is true.

If workedOvertime = True Then
pay = pay * 1.5
End If

7. Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than or equal to 65, and adds 1 to the variable nonSeniors otherwise.

If age >= 65 Then
seniorCitizens = seniorCitizens + 1
Else
nonSenior = nonSenior + 1
End If

8. Write an if/else statement that compares the value of the variables soldYesterday and soldToday, and based upon that comparison assigns salesTrend the value -1 (soldYesterday greater than soldToday) or 1.

If soldUesterday > soldToday Then
salesTrend = -1
Else
salesTrend = 1
End If

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

If temperature > 98.6 Then
fever = True
Else
fever = False
End If

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

If age < 18 Then
minors = minors + 1
Else
If (age = 18 And age < 65) Then
adults = adults + 1
Else
seniors = seniors + 1
End If

11. Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the integer variables neutral, base, and acid:

0,0,1 if pH is less than 7
0,1,0 if pH is greater than 7
1,0,0 if pH is equal to 7

If pH < 7 Then
neutral = 0
base = 0
acid = 1
Else
If pH > 7 Then
neutral = 0
base = 1
acid = 0
Else
neutral = 1
base = 0
acid = 0
End If

12. Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

If x > y Then
Max = x
Else
Max = y
End If

13. Write code that displays the message "equal" if two integer variables a and b are more than zero and equal to each other, otherwise if both variables are more than zero display "positive", otherwise display "opposites" if only one variable is more than zero.

If a > 0 And b > 0 And a = b Then
MsgBox "equal"
Else
If a > 0 And b > 0 Then
MsgBox "Positive"
Else
If a > 0 Or b > 0 Then
MsgBox "Opposites"
End If

14. Write code that displays the message "opposites" if only one of two integer variables, a and b is more than zero.

If a > 0 Or b > 0 Then
MsgBox "Opposites"
End If

15. Write code that displays "No Success" if a boolean variable x is not True. *

If x <> True Then
MsgBox "No Success"
End If

16. Write code that demonstartes how to declare a boolean variable, then assign it to a boolean expression. Add a a one line comment to explain what the code is doing. *

If customer = True Then
newcustomer = True
Else
newcustomer = False
End If

17. Explain the difference between:
textbox1.text & textbox2.text and
textbox1.text+textbox2.text
use an example.

textbox1.text & textbox2.text => it represents the and operator which compares the value in both the textbox
textbox1.text + textbox2.text => it add the value from both the text box