Create an application that calculates and display two raise amounts, which are based on an employee's current salary. The current salary will be entered by the user. The two raise rates are 5% and 8%. In addition to the raise amounts, the application should also calculate and display the employee's new salaries. Include a button in the interface that the user can click to clear the user input and calculated results from the screen.
Public Class Form1
''' <summary>
''' Calculate button
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim currentSalary As Double
Double.TryParse(txtCurrentSalary.Text, currentSalary)
Dim newSalaryRaiseRates5 As Double = currentSalary + currentSalary * 0.05D
Dim newSalaryRaiseRates8 As Double = newSalaryRaiseRates5 + newSalaryRaiseRates5 * 0.08D
txtNewSalaryRaiseRates5.Text = newSalaryRaiseRates5.ToString("C")
txtNewSalaryRaiseRates8.Text = newSalaryRaiseRates8.ToString("C")
End Sub
''' <summary>
''' Clear button
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtCurrentSalary.Text = ""
txtNewSalaryRaiseRates5.Text = ""
txtNewSalaryRaiseRates8.Text = ""
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.txtCurrentSalary = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.txtNewSalaryRaiseRates5 = New System.Windows.Forms.TextBox()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtNewSalaryRaiseRates8 = New System.Windows.Forms.TextBox()
Me.btnClear = New System.Windows.Forms.Button()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(20, 31)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(95, 13)
Me.Label1.TabIndex = 0
Me.Label1.Text = "The current salary:"
'
'txtCurrentSalary
'
Me.txtCurrentSalary.Location = New System.Drawing.Point(175, 27)
Me.txtCurrentSalary.Name = "txtCurrentSalary"
Me.txtCurrentSalary.Size = New System.Drawing.Size(100, 20)
Me.txtCurrentSalary.TabIndex = 0
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(20, 78)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(154, 13)
Me.Label2.TabIndex = 0
Me.Label2.Text = "New salary (raise rates are 5%):"
'
'txtNewSalaryRaiseRates5
'
Me.txtNewSalaryRaiseRates5.Location = New System.Drawing.Point(175, 74)
Me.txtNewSalaryRaiseRates5.Name = "txtNewSalaryRaiseRates5"
Me.txtNewSalaryRaiseRates5.ReadOnly = True
Me.txtNewSalaryRaiseRates5.Size = New System.Drawing.Size(100, 20)
Me.txtNewSalaryRaiseRates5.TabIndex = 1
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(20, 104)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(154, 13)
Me.Label3.TabIndex = 0
Me.Label3.Text = "New salary (raise rates are 8%):"
'
'txtNewSalaryRaiseRates8
'
Me.txtNewSalaryRaiseRates8.Location = New System.Drawing.Point(175, 100)
Me.txtNewSalaryRaiseRates8.Name = "txtNewSalaryRaiseRates8"
Me.txtNewSalaryRaiseRates8.ReadOnly = True
Me.txtNewSalaryRaiseRates8.Size = New System.Drawing.Size(100, 20)
Me.txtNewSalaryRaiseRates8.TabIndex = 2
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(200, 140)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(75, 23)
Me.btnClear.TabIndex = 4
Me.btnClear.Text = "Clear"
Me.btnClear.UseVisualStyleBackColor = True
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(119, 140)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(75, 23)
Me.btnCalculate.TabIndex = 3
Me.btnCalculate.Text = "Calculate"
Me.btnCalculate.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(304, 184)
Me.Controls.Add(Me.btnCalculate)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.txtNewSalaryRaiseRates8)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtNewSalaryRaiseRates5)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtCurrentSalary)
Me.Controls.Add(Me.Label1)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Two raise rates"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtCurrentSalary As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtNewSalaryRaiseRates5 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtNewSalaryRaiseRates8 As System.Windows.Forms.TextBox
Friend WithEvents btnClear As System.Windows.Forms.Button
Friend WithEvents btnCalculate As System.Windows.Forms.Button
End Class
Comments
Leave a comment