' ****************************** ' Brandon Smith ' This program prompts the user to input a price at which they buy ' a car, the trade-in value of their current car, and whether or ' not they want a stereo, leather interior, and a GPS in their new ' car, and also the sort of exterior finish they wish their new car ' to have. It then allows them to calculate the price of their acc- ' essories and finish, the tax applied to the price of the car, a ' subtotal, and finally the final price with the reduction of the ' trade-in value of their current car. They may then choose to ' calculate and display the monthly payment for a range of 1 to 10 ' years' time. Finally, they are able to clear the form, view the ' name(s) of the author(s) via the Help menu, and to exit the form. ' ****************************** Option Strict On Public Class frmOlatheAutoCenter Inherits System.Windows.Forms.Form #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 btnExit As System.Windows.Forms.Button Friend WithEvents btnClear As System.Windows.Forms.Button Friend WithEvents btnCalculate As System.Windows.Forms.Button Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents radStandard As System.Windows.Forms.RadioButton Friend WithEvents radPearlized As System.Windows.Forms.RadioButton Friend WithEvents radCustomized As System.Windows.Forms.RadioButton Friend WithEvents chkStereo As System.Windows.Forms.CheckBox Friend WithEvents chkLeather As System.Windows.Forms.CheckBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label 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 lblAccessories As System.Windows.Forms.Label Friend WithEvents lblTax As System.Windows.Forms.Label Friend WithEvents lblSubtotal As System.Windows.Forms.Label Friend WithEvents lblAmount As System.Windows.Forms.Label Friend WithEvents txtSalesPrice As System.Windows.Forms.TextBox Friend WithEvents txtTradeIn As System.Windows.Forms.TextBox Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ClearToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents FinancesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents CalculatePriceToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents HelpToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents AboutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator Friend WithEvents FinancesToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents chkNavigation As System.Windows.Forms.CheckBox Private Sub InitializeComponent() Me.btnExit = New System.Windows.Forms.Button Me.btnClear = New System.Windows.Forms.Button Me.btnCalculate = New System.Windows.Forms.Button Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.chkNavigation = New System.Windows.Forms.CheckBox Me.chkLeather = New System.Windows.Forms.CheckBox Me.chkStereo = New System.Windows.Forms.CheckBox Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.radCustomized = New System.Windows.Forms.RadioButton Me.radPearlized = New System.Windows.Forms.RadioButton Me.radStandard = New System.Windows.Forms.RadioButton Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.txtSalesPrice = New System.Windows.Forms.TextBox Me.txtTradeIn = New System.Windows.Forms.TextBox Me.lblAccessories = New System.Windows.Forms.Label Me.lblTax = New System.Windows.Forms.Label Me.lblSubtotal = New System.Windows.Forms.Label Me.lblAmount = New System.Windows.Forms.Label Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.ClearToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.FinancesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.CalculatePriceToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.FinancesToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.MenuStrip1.SuspendLayout() Me.SuspendLayout() ' 'btnExit ' Me.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnExit.Location = New System.Drawing.Point(436, 259) Me.btnExit.Name = "btnExit" Me.btnExit.Size = New System.Drawing.Size(75, 23) Me.btnExit.TabIndex = 0 Me.btnExit.Text = "E&xit" ' 'btnClear ' Me.btnClear.Location = New System.Drawing.Point(340, 259) Me.btnClear.Name = "btnClear" Me.btnClear.Size = New System.Drawing.Size(75, 23) Me.btnClear.TabIndex = 1 Me.btnClear.Text = "C&lear" ' 'btnCalculate ' Me.btnCalculate.Location = New System.Drawing.Point(228, 259) Me.btnCalculate.Name = "btnCalculate" Me.btnCalculate.Size = New System.Drawing.Size(96, 23) Me.btnCalculate.TabIndex = 2 Me.btnCalculate.Text = "&Calculate Price" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.chkNavigation) Me.GroupBox1.Controls.Add(Me.chkLeather) Me.GroupBox1.Controls.Add(Me.chkStereo) Me.GroupBox1.Location = New System.Drawing.Point(12, 27) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(200, 112) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Accessories" ' 'chkNavigation ' Me.chkNavigation.Location = New System.Drawing.Point(8, 80) Me.chkNavigation.Name = "chkNavigation" Me.chkNavigation.Size = New System.Drawing.Size(144, 24) Me.chkNavigation.TabIndex = 2 Me.chkNavigation.Text = "&GPS System" ' 'chkLeather ' Me.chkLeather.Location = New System.Drawing.Point(8, 48) Me.chkLeather.Name = "chkLeather" Me.chkLeather.Size = New System.Drawing.Size(112, 24) Me.chkLeather.TabIndex = 1 Me.chkLeather.Text = "Leather &Interior" ' 'chkStereo ' Me.chkStereo.Location = New System.Drawing.Point(8, 16) Me.chkStereo.Name = "chkStereo" Me.chkStereo.Size = New System.Drawing.Size(112, 24) Me.chkStereo.TabIndex = 0 Me.chkStereo.Text = "&Stereo System" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.radCustomized) Me.GroupBox2.Controls.Add(Me.radPearlized) Me.GroupBox2.Controls.Add(Me.radStandard) Me.GroupBox2.Location = New System.Drawing.Point(12, 163) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(200, 120) Me.GroupBox2.TabIndex = 4 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Car Exterior Finish" ' 'radCustomized ' Me.radCustomized.Location = New System.Drawing.Point(8, 88) Me.radCustomized.Name = "radCustomized" Me.radCustomized.Size = New System.Drawing.Size(144, 24) Me.radCustomized.TabIndex = 2 Me.radCustomized.Text = "Customized &Detailing" ' 'radPearlized ' Me.radPearlized.Location = New System.Drawing.Point(8, 56) Me.radPearlized.Name = "radPearlized" Me.radPearlized.Size = New System.Drawing.Size(104, 24) Me.radPearlized.TabIndex = 1 Me.radPearlized.Text = "P&earlized" ' 'radStandard ' Me.radStandard.Checked = True Me.radStandard.Location = New System.Drawing.Point(8, 24) Me.radStandard.Name = "radStandard" Me.radStandard.Size = New System.Drawing.Size(104, 24) Me.radStandard.TabIndex = 0 Me.radStandard.TabStop = True Me.radStandard.Text = "S&tandard" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(260, 35) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(100, 23) Me.Label1.TabIndex = 5 Me.Label1.Text = "Car's Sales Price:" Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(236, 67) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(128, 23) Me.Label2.TabIndex = 6 Me.Label2.Text = "Accessories and Finish:" Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(268, 99) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(100, 23) Me.Label3.TabIndex = 7 Me.Label3.Text = "Sales Tax (8%):" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label4 ' Me.Label4.Location = New System.Drawing.Point(268, 131) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(100, 23) Me.Label4.TabIndex = 8 Me.Label4.Text = "Subtotal:" Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label5 ' Me.Label5.Location = New System.Drawing.Point(268, 163) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(104, 23) Me.Label5.TabIndex = 9 Me.Label5.Text = "Trade-in Allowance:" Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label6 ' Me.Label6.Location = New System.Drawing.Point(268, 195) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(100, 23) Me.Label6.TabIndex = 10 Me.Label6.Text = "Amount Due:" Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'txtSalesPrice ' Me.txtSalesPrice.Location = New System.Drawing.Point(372, 35) Me.txtSalesPrice.Name = "txtSalesPrice" Me.txtSalesPrice.Size = New System.Drawing.Size(144, 20) Me.txtSalesPrice.TabIndex = 11 Me.txtSalesPrice.Text = "$0.00" Me.txtSalesPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'txtTradeIn ' Me.txtTradeIn.Location = New System.Drawing.Point(372, 163) Me.txtTradeIn.Name = "txtTradeIn" Me.txtTradeIn.Size = New System.Drawing.Size(144, 20) Me.txtTradeIn.TabIndex = 15 Me.txtTradeIn.Text = "$0.00" Me.txtTradeIn.TextAlign = System.Windows.Forms.HorizontalAlignment.Right ' 'lblAccessories ' Me.lblAccessories.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblAccessories.Location = New System.Drawing.Point(372, 67) Me.lblAccessories.Name = "lblAccessories" Me.lblAccessories.Size = New System.Drawing.Size(144, 23) Me.lblAccessories.TabIndex = 16 Me.lblAccessories.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblTax ' Me.lblTax.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblTax.Location = New System.Drawing.Point(372, 99) Me.lblTax.Name = "lblTax" Me.lblTax.Size = New System.Drawing.Size(144, 23) Me.lblTax.TabIndex = 17 Me.lblTax.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblSubtotal ' Me.lblSubtotal.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblSubtotal.Location = New System.Drawing.Point(372, 131) Me.lblSubtotal.Name = "lblSubtotal" Me.lblSubtotal.Size = New System.Drawing.Size(144, 23) Me.lblSubtotal.TabIndex = 18 Me.lblSubtotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblAmount ' Me.lblAmount.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblAmount.Location = New System.Drawing.Point(372, 195) Me.lblAmount.Name = "lblAmount" Me.lblAmount.Size = New System.Drawing.Size(144, 23) Me.lblAmount.TabIndex = 19 Me.lblAmount.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'MenuStrip1 ' Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.FinancesToolStripMenuItem, Me.HelpToolStripMenuItem}) Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = New System.Drawing.Size(526, 24) Me.MenuStrip1.TabIndex = 20 Me.MenuStrip1.Text = "MenuStrip1" ' 'FileToolStripMenuItem ' Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ClearToolStripMenuItem, Me.ToolStripSeparator1, Me.ExitToolStripMenuItem}) Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" Me.FileToolStripMenuItem.Size = New System.Drawing.Size(35, 20) Me.FileToolStripMenuItem.Text = "&File" ' 'ClearToolStripMenuItem ' Me.ClearToolStripMenuItem.Name = "ClearToolStripMenuItem" Me.ClearToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.ClearToolStripMenuItem.Text = "&Clear" ' 'ToolStripSeparator1 ' Me.ToolStripSeparator1.Name = "ToolStripSeparator1" Me.ToolStripSeparator1.Size = New System.Drawing.Size(149, 6) ' 'ExitToolStripMenuItem ' Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.ExitToolStripMenuItem.Text = "E&xit" ' 'FinancesToolStripMenuItem ' Me.FinancesToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CalculatePriceToolStripMenuItem, Me.FinancesToolStripMenuItem1}) Me.FinancesToolStripMenuItem.Name = "FinancesToolStripMenuItem" Me.FinancesToolStripMenuItem.Size = New System.Drawing.Size(61, 20) Me.FinancesToolStripMenuItem.Text = "Fi&nances" ' 'CalculatePriceToolStripMenuItem ' Me.CalculatePriceToolStripMenuItem.Name = "CalculatePriceToolStripMenuItem" Me.CalculatePriceToolStripMenuItem.Size = New System.Drawing.Size(155, 22) Me.CalculatePriceToolStripMenuItem.Text = "Calculate Price" ' 'FinancesToolStripMenuItem1 ' Me.FinancesToolStripMenuItem1.Name = "FinancesToolStripMenuItem1" Me.FinancesToolStripMenuItem1.Size = New System.Drawing.Size(155, 22) Me.FinancesToolStripMenuItem1.Text = "Payments" ' 'HelpToolStripMenuItem ' Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AboutToolStripMenuItem}) Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem" Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(40, 20) Me.HelpToolStripMenuItem.Text = "&Help" ' 'AboutToolStripMenuItem ' Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem" Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(152, 22) Me.AboutToolStripMenuItem.Text = "&About" ' 'frmOlatheAutoCenter ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.btnExit Me.ClientSize = New System.Drawing.Size(526, 292) Me.Controls.Add(Me.lblAmount) Me.Controls.Add(Me.lblSubtotal) Me.Controls.Add(Me.lblTax) Me.Controls.Add(Me.lblAccessories) Me.Controls.Add(Me.txtTradeIn) Me.Controls.Add(Me.txtSalesPrice) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.btnCalculate) Me.Controls.Add(Me.btnClear) Me.Controls.Add(Me.btnExit) Me.Controls.Add(Me.MenuStrip1) Me.MainMenuStrip = Me.MenuStrip1 Me.Name = "frmOlatheAutoCenter" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Olathe Auto Center" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.MenuStrip1.ResumeLayout(False) Me.MenuStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub #End Region Const decSTEREO_SYSTEM As Decimal = 425.76D Const decLEATHER_INTERIOR As Decimal = 987.41D Const decGPS_SYSTEM As Decimal = 1741.23D Const decPEARLIZED As Decimal = 345.72D Const decCUSTOM_DETAILING As Decimal = 599.99D Const decSALES_TAX As Decimal = 0.08D Const decLOAN_INTEREST As Decimal = 0.03D Dim decCurrentPrice As Decimal Private Sub CalculatePrice() Dim decReturnPrice As Decimal If (chkStereo.Checked) Then decReturnPrice += decSTEREO_SYSTEM End If If (chkLeather.Checked) Then decReturnPrice += decLEATHER_INTERIOR End If If (chkNavigation.Checked) Then decReturnPrice += decGPS_SYSTEM End If If (radPearlized.Checked) Then decReturnPrice += decPEARLIZED ElseIf (radCustomized.Checked) Then decReturnPrice += decCUSTOM_DETAILING End If lblAccessories.Text = FormatCurrency(decReturnPrice) decReturnPrice += CDec(txtSalesPrice.Text) lblTax.Text = FormatCurrency(CDec(decReturnPrice * decSALES_TAX)) decReturnPrice += CDec(decReturnPrice * decSALES_TAX) lblSubtotal.Text = FormatCurrency(decReturnPrice) decReturnPrice -= CDec(txtTradeIn.Text) lblAmount.Text = FormatCurrency(decReturnPrice) decCurrentPrice = decReturnPrice End Sub Private Sub Clear() chkStereo.Checked = False chkLeather.Checked = False chkNavigation.Checked = False radStandard.Checked = True radPearlized.Checked = False radCustomized.Checked = False txtSalesPrice.Text = "$0.00" txtTradeIn.Text = "$0.00" lblAccessories.Text = "" lblTax.Text = "" lblSubtotal.Text = "" lblAmount.Text = "" End Sub Private Function CalculatePayment(ByVal L As Decimal, ByVal c As Double, ByVal n As Double) As Decimal Return CDec(L * (c * (1 + c) ^ n) / ((1 + c) ^ n - 1)) End Function Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click CalculatePrice() End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click Clear() End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click Clear() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub Private Sub CalculatePriceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculatePriceToolStripMenuItem.Click CalculatePrice() End Sub Private Sub FinancesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FinancesToolStripMenuItem1.Click Dim strResult As String = "" Dim intYear As Integer = 1 While (intYear <= 10) strResult &= "Paying off in " & CStr(intYear) & " year(s): " & FormatCurrency(CalculatePayment(decCurrentPrice, decLOAN_INTEREST / 12, intYear * 12)) & " per month." If (intYear < 10) Then strResult &= ControlChars.NewLine End If intYear += 1 End While MessageBox.Show(strResult, "Payments Calculated at 3% Interest", MessageBoxButtons.OK) End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click MessageBox.Show("Form designed by Dr. Mark Van Gorp" & ControlChars.NewLine & "Form additions and programming by Brandon Smith", "About", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class