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

Chapter 5 – Section 2: Sub Procedures, Part 1 In Exercises 3 through 19, determi

ID: 3741687 • Letter: C

Question

Chapter 5 – Section 2: Sub Procedures, Part 1

In Exercises 3 through 19, determine the output displayed when the button is clicked. (Check the assumptions when listed at the end of the exercise)

3.    Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   Dim Color As String

   Color = InputBox(“What is your favorite color?”)

   Flattery(color)

End Sub

Sub Flattery(color As String)

   txtOutput.Text = “You look dashing in ” & color & “.”

End Sub

(Assume the response is blue)

5.     Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   Dim hours As Double

   hours = 24

   Minutes(60 * hours)

End Sub

Sub Minutes(num As Double)

   txtOutput.Text = num & “ minutes in a day”

End Sub

7.     Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   Question()

   Answer()

End Sub

Sub Answer()

   lstOutput.Items.Add(“Because they were invented in the northern”)

   lstOutput.Items.Add(“hemisphere where sundials go clockwise”)

End Sub

Sub Question()

   lstOutput.Items.Add(“Why do clocks run clockwise?”)

   lstOutput.Items.Add(“”)

End Sub

9.   Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   ‘Beginning of Tale of Two Cities

   Times(“best”)

   Times(“worst”)

End Sub

Sub Times(word As String)

   ‘Display sentence

   lstOutput.Items.Add(“It was the ” & word & “ of times”

End Sub

11.   Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   ‘The fates of Henry the Eighth’s six wives

   CommonFates()

   lstOutput.Items.Add(“died”)

   CommonFates()

   lstOutput.Items.Add(“survived”)

End Sub

Sub CommonFates()

   ‘The most common fates

   lstOutput.Items.Add(“divorced”)

   lstOutput.Items.Add(“beheaded”)

End Sub

13.    Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   HowMany(24)

   lstOutput.Items.Add(“a pie”)

End Sub

Sub HowMany(num As Integer)

   What(num)

   lstOutput.Items.Add(“baked in”)

End Sub

Sub What(num As Integer)

   lstOutput.Items.Add(num & “ blackbirds”)

End Sub

15.    Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

   Dim word As String, num As Integer

   Word = “Visual Basic”

   Num = 6

   FirstPart(word, num)

End Sub

Sub FirstPart(term As String, digit As Integer)

   txtOutput.Text = “The first “ & digit & “ letters are “ &

                     term.Substring(0, digit) & “.”

End Sub

17. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

Dim cost As Double = 250

DisplayBill(cost, ShippingCost(cost))

   End Sub

   Function ShippingCost(costOfGoods As Double) As Double

Select Case costOfGoods

Case Is < 100

    Return 10

Case Is < 500

    Return 15

Case Else

    Return 20

End Select

   End Function

   Sub DisplayBill(cost As Double, addedCost As Double)

lstOutput.Items.Add(“Cost: ” & cost.ToString(“C”))

lstOutput.Items.Add(“ShippingCost: ” & addedCost.ToString(“C”))

lstOutput.Items.Add(“Total cost: ” & (cost + addedCost).ToString(“C”))

        End Sub

19. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

Dim grade = CDbl(InputBox(“What is your numeric grade?”, “Grade”))

ShowResult(grade)

   End Sub

   Sub ShowResult(grade As Double)

      If (grade < 0 ) Or (grade > 100) Then

         MessageBox.Show(“Improper grade”)

         Exit Sub

      End If

      If PassedExam(grade) Then

         txtOutput.Text = “You passed with a grade of “ & grade & “.”

      Else

         txtOutput.Text = “You failed the exam.”

      End If

        End Sub

(Assume the response is 92.)

In Exercise 21 find the errors.

21. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click

Dim n As Integer = 5

Alphabet()

   End Sub

   Sub Alphabet(n As Integer)

      txtOutput.Text = “abcdefghijklmnopqrstuvwxyz”.Substring(0, n)

        End Sub

Explanation / Answer

Please find my answer for first 4 Questions.

Please repsot others in separate post.

Q3.
  
   Output:
       WHat is your favourite color: user input
       You look dashing in blue.

Q5.
   1440 minutes in a day

Q7.
   Why do clocks run clockwise?
   Because they were invented in the northern
   hemisphere where sundials go clockwise

Q9.
   It was the best of time
   It was the worst of time

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote