Option Explicit On Option Strict On 'Paul Barna '2/21/05 'barnap1@lasalle.edu 'The purpose of this program is to calculate tuition for a college along with any discounts that may apply. Public Class Form1 Inherits System.Windows.Forms.Form Const inStateFirst12 As Double = 500 Const inStateNext9 As Double = 100 Const outStateFirst12 As Double = 900 Const outStateNext9 As Double = 300 Const discount As Double = 0.2 Const maxCredits As Double = 21 Const dormCost As Double = 4000 #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TxtCredits As System.Windows.Forms.TextBox Friend WithEvents ChkInState As System.Windows.Forms.CheckBox Friend WithEvents ChkResident As System.Windows.Forms.CheckBox Friend WithEvents BtnCalc As System.Windows.Forms.Button Friend WithEvents BtnClear As System.Windows.Forms.Button Friend WithEvents BtnQuit As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TxtBasic As System.Windows.Forms.TextBox Friend WithEvents TxtDiscount As System.Windows.Forms.TextBox Friend WithEvents TxtFinal As System.Windows.Forms.TextBox Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents TxtBoard As System.Windows.Forms.TextBox Friend WithEvents TxtTotal As System.Windows.Forms.TextBox Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TxtCredits = New System.Windows.Forms.TextBox Me.ChkInState = New System.Windows.Forms.CheckBox Me.ChkResident = New System.Windows.Forms.CheckBox Me.BtnCalc = New System.Windows.Forms.Button Me.BtnClear = New System.Windows.Forms.Button Me.BtnQuit = New System.Windows.Forms.Button Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.TxtBasic = New System.Windows.Forms.TextBox Me.TxtDiscount = New System.Windows.Forms.TextBox Me.TxtFinal = New System.Windows.Forms.TextBox Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.TxtBoard = New System.Windows.Forms.TextBox Me.TxtTotal = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Underline), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(64, 8) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(400, 27) Me.Label1.TabIndex = 0 Me.Label1.Text = "The Penn State - Germantown Campus" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(64, 72) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(152, 24) Me.Label2.TabIndex = 1 Me.Label2.Text = "Number of Credits" ' 'TxtCredits ' Me.TxtCredits.Location = New System.Drawing.Point(368, 72) Me.TxtCredits.Name = "TxtCredits" Me.TxtCredits.Size = New System.Drawing.Size(96, 20) Me.TxtCredits.TabIndex = 2 Me.TxtCredits.Text = "" Me.TxtCredits.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'ChkInState ' Me.ChkInState.Location = New System.Drawing.Point(104, 112) Me.ChkInState.Name = "ChkInState" Me.ChkInState.Size = New System.Drawing.Size(72, 32) Me.ChkInState.TabIndex = 3 Me.ChkInState.Text = "In-State Resident" ' 'ChkResident ' Me.ChkResident.Location = New System.Drawing.Point(352, 112) Me.ChkResident.Name = "ChkResident" Me.ChkResident.Size = New System.Drawing.Size(72, 32) Me.ChkResident.TabIndex = 4 Me.ChkResident.Text = "Resident Student" ' 'BtnCalc ' Me.BtnCalc.Location = New System.Drawing.Point(176, 160) Me.BtnCalc.Name = "BtnCalc" Me.BtnCalc.Size = New System.Drawing.Size(72, 24) Me.BtnCalc.TabIndex = 5 Me.BtnCalc.Text = "Calculate" ' 'BtnClear ' Me.BtnClear.Location = New System.Drawing.Point(280, 160) Me.BtnClear.Name = "BtnClear" Me.BtnClear.Size = New System.Drawing.Size(72, 24) Me.BtnClear.TabIndex = 6 Me.BtnClear.Text = "Clear" ' 'BtnQuit ' Me.BtnQuit.Location = New System.Drawing.Point(224, 408) Me.BtnQuit.Name = "BtnQuit" Me.BtnQuit.Size = New System.Drawing.Size(72, 24) Me.BtnQuit.TabIndex = 7 Me.BtnQuit.Text = "Exit" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(64, 208) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(112, 24) Me.Label3.TabIndex = 8 Me.Label3.Text = "Basic Tuition" ' 'Label4 ' Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label4.Location = New System.Drawing.Point(64, 248) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(80, 24) Me.Label4.TabIndex = 9 Me.Label4.Text = "Discount" ' 'Label5 ' Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.Location = New System.Drawing.Point(64, 288) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(104, 24) Me.Label5.TabIndex = 10 Me.Label5.Text = "Final Tuition" ' 'TxtBasic ' Me.TxtBasic.Location = New System.Drawing.Point(368, 208) Me.TxtBasic.Name = "TxtBasic" Me.TxtBasic.ReadOnly = True Me.TxtBasic.Size = New System.Drawing.Size(96, 20) Me.TxtBasic.TabIndex = 11 Me.TxtBasic.Text = "" Me.TxtBasic.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'TxtDiscount ' Me.TxtDiscount.Location = New System.Drawing.Point(368, 248) Me.TxtDiscount.Name = "TxtDiscount" Me.TxtDiscount.ReadOnly = True Me.TxtDiscount.Size = New System.Drawing.Size(96, 20) Me.TxtDiscount.TabIndex = 12 Me.TxtDiscount.Text = "" Me.TxtDiscount.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'TxtFinal ' Me.TxtFinal.Location = New System.Drawing.Point(368, 288) Me.TxtFinal.Name = "TxtFinal" Me.TxtFinal.ReadOnly = True Me.TxtFinal.Size = New System.Drawing.Size(96, 20) Me.TxtFinal.TabIndex = 13 Me.TxtFinal.Text = "" Me.TxtFinal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'Label6 ' Me.Label6.Location = New System.Drawing.Point(464, 424) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(64, 16) Me.Label6.TabIndex = 14 Me.Label6.Text = "Paul Barna" ' 'Label7 ' Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label7.Location = New System.Drawing.Point(64, 368) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(88, 24) Me.Label7.TabIndex = 15 Me.Label7.Text = "Total Cost" ' 'Label8 ' Me.Label8.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label8.Location = New System.Drawing.Point(64, 328) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(136, 24) Me.Label8.TabIndex = 16 Me.Label8.Text = "Room and Board" ' 'TxtBoard ' Me.TxtBoard.Location = New System.Drawing.Point(368, 328) Me.TxtBoard.Name = "TxtBoard" Me.TxtBoard.ReadOnly = True Me.TxtBoard.Size = New System.Drawing.Size(96, 20) Me.TxtBoard.TabIndex = 17 Me.TxtBoard.Text = "" Me.TxtBoard.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'TxtTotal ' Me.TxtTotal.Location = New System.Drawing.Point(368, 368) Me.TxtTotal.Name = "TxtTotal" Me.TxtTotal.ReadOnly = True Me.TxtTotal.Size = New System.Drawing.Size(96, 20) Me.TxtTotal.TabIndex = 18 Me.TxtTotal.Text = "" Me.TxtTotal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(528, 445) Me.Controls.Add(Me.TxtTotal) Me.Controls.Add(Me.TxtBoard) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.TxtFinal) Me.Controls.Add(Me.TxtDiscount) Me.Controls.Add(Me.TxtBasic) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.BtnQuit) Me.Controls.Add(Me.BtnClear) Me.Controls.Add(Me.BtnCalc) Me.Controls.Add(Me.ChkResident) Me.Controls.Add(Me.ChkInState) Me.Controls.Add(Me.TxtCredits) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub BtnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnQuit.Click 'exit from program Me.Close() End Sub Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click 'clear all textboxes and checkboxes TxtCredits.Text = ("") TxtBasic.Text = ("") TxtDiscount.Text = ("") TxtFinal.Text = ("") TxtBoard.Text = ("") TxtTotal.Text = ("") ChkInState.Checked = False ChkResident.Checked = False End Sub Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click 'declare variables Dim totalCredits As Int32 Dim basicTuition As Double Dim totalDiscount As Double Dim finalTuition As Double Dim board As Double Dim totalCost As Double 'determine if credits is a number If IsNumeric(TxtCredits.Text) Then totalCredits = Convert.ToInt32(TxtCredits.Text) Else MsgBox("Please enter a numeric value for Total Credits", MsgBoxStyle.OKOnly, "Error") End If 'determine if number of credits in <= maxCredits If totalCredits > 0 And totalCredits <= maxCredits Then 'create branch for in state student If ChkInState.Checked = True Then If totalCredits >= 1 And totalCredits <= 12 Then basicTuition = totalCredits * inStateFirst12 TxtBasic.Text = basicTuition.ToString("c2") Else basicTuition = (12 * inStateFirst12) + ((totalCredits - 12) * inStateNext9) TxtBasic.Text = basicTuition.ToString("c2") End If End If 'create branch for out of state student If ChkInState.Checked = False Then If totalCredits >= 1 And totalCredits <= 12 Then basicTuition = totalCredits * outStateFirst12 TxtBasic.Text = basicTuition.ToString("c2") Else basicTuition = (12 * outStateFirst12) + ((totalCredits - 12) * outStateNext9) TxtBasic.Text = basicTuition.ToString("c2") End If End If 'create branch for resident student If ChkResident.Checked = True Then totalDiscount = (basicTuition * discount) TxtDiscount.Text = totalDiscount.ToString("c2") Else totalDiscount = 0 TxtDiscount.Text = totalDiscount.ToString("c2") End If 'create code for final tuition by subtracting basic tution and total discount finalTuition = basicTuition - totalDiscount TxtFinal.Text = finalTuition.ToString("c2") 'create branch for room and board cost If ChkResident.Checked = True Then board = dormCost TxtBoard.Text = board.ToString("c2") Else board = 0 TxtBoard.Text = board.ToString("c2") End If 'create code for total cost by adding final tuition and room and board totalCost = finalTuition + board TxtTotal.Text = totalCost.ToString("c2") Else MsgBox("Please enter a number between 1 and 21", MsgBoxStyle.OKOnly, "Error") End If End Sub End Class