Could someone translate this vb code to structure english? (i.e declare mailbox,
ID: 3819336 • Letter: C
Question
Could someone translate this vb code to structure english? (i.e declare mailbox, call procedure, etc)
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
'Declare the required variables
Dim currentbal, withdrawal, newbal As Double
Get the input of number of "current balance and "withdrawal amount in string type and then convert the amount into double data type.
'read the input from user
currentbal = CDbl(InputBox("Enter the current balance"))
withdrawal = CDbl(InputBox("Enter the withdrawal amount"))
Check whether the withdrawal amount is greater than current balance amount. If the condition is true, then display the error message
'If the withdrawal amount is greater than current 'balance amount
If withdrawal > currentbal Then
'Display the message
MessageBox.Show ("withdrawal denied")
If the withdrawal amount is less than current balance amount then calculate the new balance amount by subtracting the withdrawal amount from current balance amount.
'If the withdrawal amount is less than current balance amount.
Else
'Subtract the withdrawal amount from current 'balance
newbal = currentbal - withdrawal
Convert the new balance amount into double data type and then print the new balance in text box.
'Display the new balance in double data type
txtBal.Text = CDbl(newbal)
If the new balance amount is less than 150 then display the message.
'If the new balance is less than 150
If newbal < 150 Then
'Display the message
MessageBox.Show("Balance below $150")
End If
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End the application
'Close the form
Me.Close()
End Sub
End Class
Explanation / Answer
Begin Procedure btnCalc_Click()
Declare variables currentbal, withdrawal, newbal
Get currentbal as a string input from user
convert currentbal to double
Get withdrawal as a string input from user
convert withdrawal to double
If the amount to be withdrawn is greater than current balance
If withdrawal is greater than currentbal Then
Begin
Display the message " withdrawal denied"
End
Else
Begin
Calculate newbal by subtracting the withdrawal amount from currentbal Convert newbal to double
Display newbal in a text box
Check if newbal is less than 150 then
display a message, " Balance below $150 "
End
End Procedure
End Application
Please let me know in case of any doubts.
Thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.