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

The problem: Create a project to compute your checking account balance. A text b

ID: 3654808 • Letter: T

Question

The problem: Create a project to compute your checking account balance. A text box will allow the user to enter the amount of the transaction. Calculate the balance by adding deposits and subtracting service charges and checks. For some reason the code that i wrote is wrong. It doesn't add deposit and doesn't subtract service charges and checks it. Here is the code that I wrote. Private Sub CalculateButton_Click(sender As System.Object, e As System.EventArgs) Handles CalculateButton.Click 'Declare amount transaction and balance. Dim AmtTran As Decimal = 0 Dim Bal As Decimal = 0 'Check the amount given by user for negative. If Decimal.Parse(AmtTranTextBox.Text) > 0 Then AmtTran = Decimal.Parse(AmtTranTextBox.Text) End If 'Check the option field selected. If DepositOpt.Checked Then 'If option is deposit then add amount to existing balance. Bal += AmtTran ElseIf CheckOpt.Checked Then If Bal >= AmtTran Then Bal -= AmtTran Else 'If check amount transaction is more than existing balance then display this to user MessageBox.Show("Balance is negative", "Error", MessageBoxButtons.OK) End If ElseIf SerChOpt.Checked Then 'If option is service charge then subtract amount from existing balance. If Bal >= AmtTran Then Bal -= AmtTran Else 'If serevice charge is more than existing amount then dispaly message. MessageBox.Show("Balance is in negative", "Error", MessageBoxButtons.OK) End If Else MessageBox.Show("Must select Deposit or Check or Service Charge", "Need to select choice", MessageBoxButtons.OK) End If 'Update Balance to New Balance text box. NewBalTextBox.Text = Bal.ToString("C")

Explanation / Answer

Dim intCBalance As Integer Dim inttrans As Integer Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalc.Click inttrans = txtTrans.Text If radDeposit.Checked = True Then If intCBalance = 0 Then lblCB.Text = "Current Balance: $" & inttrans intCBalance = inttrans End If lblCB.Text = "Current Balance: $" & intCBalance + inttrans ElseIf radCheck.Checked = True Then If intCBalance = 0 Then lblCB.Text = "Current Balance: $" & inttrans intCBalance = inttrans End If lblCB.Text = "Current Balance: $" & intCBalance - inttrans ElseIf radService.Checked = True Then If intCBalance = 0 Then lblCB.Text = "Current Balance: $" & inttrans intCBalance = inttrans End If lblCB.Text = "Current Balance: $" & intCBalance - inttrans End If End Sub