Could someone translate this VB code to structured english? (i.e. declare mailbo
ID: 3819335 • Letter: C
Question
Could someone translate this VB code to structured english? (i.e. declare mailbox)
1.Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
2. Dim oldBalance, charges, credits, newBalance, minPayment As Double
3. InputData(oldBalance, charges, credits)
4. CalculateNewValues(oldBalance, charges, credits, newBalance, minPayment)
5. DisplayData(newBalance, minPayment)
6.End Sub
7.Sub InputData(ByRef oldBalance As String, ByRef charges As String, ByRef credits As String)
8. oldBalance = CDbl(txtOldBal.Text)
9. charges = CDbl(txtCharges.Text)
10. credits = CDbl(txtCredits.Text)
11.End Sub
12.Sub CalculateNewValues(ByRef oldBalance As Double, ByRef charges As Double, ByRef credits As Double, ByRef newBalance As Double, ByRef minPayment As Double)
13. Dim rate As Double = 1.015
14. newBalance = (rate * oldBalance) + charges - credits
16. If newBalance <= 20 Then
17 minPayment = newBalance
18 Else
19 minPayment = ((newBalance - 20) * 0.1) + 20
20 End If
21.End Sub
22.Sub DisplayData(newBalance As Double, minPayment As Double)
23. lblMinPay.Text = minPayment.ToString("C")
24. lblNewBal.Text = newBalance.ToString("C")
25.End Sub
26.End Class
Explanation / Answer
Translation of this VB code in structured english is as follows:
On button click "btnCompute_Click" following things will happen
1) We have taken oldBalance, charges, credits, newBalance, minPayment as double type variable.
2) Now "InputData" function will be called. In this function, we have taken "oldBalance, charges, credits" as input from user.
3) Now "CalculateNewValues" function will be called. And the following things will be done in this function:
i) In this function we have taken rate variable of double type having value 1.015
ii) Now in this function we will calculate value of "newBalance" using formula newBalance = (rate * oldBalance) + charges - credits
iii) If newBalance is less than or equal to 20 then "minPayment" will be equal to newBalance.
iv) if newBalance is greater 20 then minPayment will be calculate using following formula minPayment = ((newBalance - 20) * 0.1) + 20
4) After "CalculateNewValues" function, "DisplayData" function will be called. By using this function we will display the value of "minPayment" and "newBalance" in the text box.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.