Number of checks written Solution (Best price and Top Grade Guaranteed)
A bank charges $10 per month plus the following check fees for a commercial checking account:
$0.10 each for less than 20 checks, $0.08 each for 20-39 checks, $0.06 each for 40-59 checks $0.04 each for 60 or more checks.
Create an application that allows the user to enter the number of checks written. The application should compute and display the bank's sevice fees for the month. All checks for the month are assigned the same charge, based on the total number of checks written during the month.
Input validation: Do not accept a negative value for the number of checks written. Ensure that all values are numeric. The Clear button must clear the text box and the label that displays the monthly service charge.
Use the following test data to determine if the application is calculating properly.
The integers are the number of checks that are entered in the textbox by the user.
15 ------------ $ 11. 50
25-------------$12.00
45-------------$12.70
75-------------$13.00
The code:
Public Class Form1
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim decBaseFee As Decimal 'Base Monthly Fee
Dim decTotalServiceFee As Integer 'Total Service Fee
Dim intChecks As Integer 'Number of Checks
Dim blnInputOk As Boolean = True
Const decSERVICE_FEE As Decimal = 10D
Const decLESS_THAN_TWENTY As Decimal = 0.1D
Const decTWENTY_TO_THIRTY_NINE As Decimal = 0.08D
Const decFORTY_TO_FIFTY_NINE As Decimal = 0.06D
Const decSIXTY_OR_MORE As Decimal = 0.04D
'Validate and ensure all values are numeric
If Integer.TryParse(txtChecks.Text, intChecks) = False Then
lblStatus.Text = "Checks must be an integer."
blnInputOk = False
End If
'Validate the number of checks. Do not accept a negative value.