This is the assignment: An internet service provider offers three subscription packages plus a discount fo nonprofit organizations.
a. Package A: 10 hours of access for $9.95 per month. Additional hours are $2.00 per hour.
b. Package B: 20 hours of access for $14.95 per month. Additonal hours are $1.00 per hour.
c. PackageC: Unlimited access for $19.95 per month.
d. Nonprofit Organizations: THe service provider gives all nonprofit organizations a 20 % discount on all packages.
The user should select a package the customer has purchased (from a set of radio buttons) and enter the number of hours used. A check box captioned Nonprofit should also appear on the form. The application should calculate and display the total amount due. If user selects Nonprofit organization check box, a 20% discount should be deducted.
Input validation: the number of hours used in a month cannot exceed 744. The value must be numeric.
vb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare
Dim PackageA As Decimal 'Package A base price
Dim PackageB As Decimal 'Package B base price
Dim PackageC As Integer 'Package C base price
Dim Hours As Decimal '# of hours in each Package
Dim Price As Integer
Dim Additional As Integer 'Additional cost over hours
Dim Total As Integer 'Total package price
'The following constants are used to calculate discounts.
'Discount can be used for package A, B, or C.
Dim Nonprofit As Decimal = 0.2D '20 %
'Calculate the base package price
If radA.Checked = True Then
PackageA = 9.95
lblTotal.Text = FormatCurrency(PackageA)
ElseIf Hours > 10 Then
Additional += 2.0
lblTotal.Text = (PackageA)
End If
If RadB.Checked = True Then
PackageB = 14.95
lblTotal.Text = FormatCurrency(PackageB)
End If
If RadC.Checked = True Then
PackageC = 19.95
lblTotal.Text = FormatCurrency(PackageC)
End If
'# of hours used in each package
'Determine the discount, based nonprofit organization
If radA.Checked And ChkNonprofit.Checked = True Then
Price = PackageA * Nonprofit
lblTotal.Text = FormatCurrency(PackageA - 1.99)
ElseIf RadB.Checked And ChkNonprofit.Checked = True Then
Price = 14.95 - 0.2
lblTotal.Text = FormatCurrency(PackageB - 2.99)
ElseIf RadC.Checked And ChkNonprofit.Checked = True Then
lblTotal.Text = FormatCurrency(PackageC - 3.99)
End If
'Display the Total
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
EDIT: Code blocks added
This post has been edited by PsychoCoder: 13 Apr, 2008 - 04:39 PM