|
-
Dec 15th, 2007, 11:11 PM
#1
Thread Starter
New Member
Earning Calculator
Hi All,
Got this lab that's causing me pain. It's just not calculating the increments. Can somebody help? Here's the instructions:
This program will implement a "Lifetime Earnings" calculator, which will compute the user's lifetime earnings and the ending salary, from the present year until his/her retirement age. The program will request a few data elements from the user: name, current age, current annual salary, retirements age, gender, and average percentual salary raise expected from now until retirement. The program will apply the raise to each future year's salary, and thus compute the accumulated earnings between and ending salary.
Let's work on an example. Let's assume that a person has 18 years of age, earns $15,000/year, plans to retire at 65, and expects an average raise of 3% each year. We won't compute all years, of course, but let's compute the first couple of years (the accumulated earnings are assumed to begin at zero):
Year 18 -- Salary = 15000; Raise = 3%; at the end of this first year, the raise will be 15000 x 3% = 450; so, the ending salary that first year will be 15000 + 450 = 15450. The accumulated earnings will then be 0 + 15450 = 15450.
Year 19 -- Salary = 15450; Raise = 3%; at the end of the second year, the raise wll be 15450 x 3% = 463.50; so, the ending salary the second year will be 15450 + 463.50 = 15913.50. The accumulated earnings will then be 15450 + 15913.50 = 31363.50.
If you continue doing these computations until the year 65, then you will end up with the salary at the end of those years: 61983.78, and an accumulated earnings of 1566125.94.
The program will use the gender of the person to fine tune the resulting message with "...his final salary..." or "...her final salary...".
Code:
Option Explicit On
Option Strict On
Imports System.Globalization
Public Class Form1
Dim firstN As String
Dim intAge As Integer
Dim retAge As Integer
Dim canSal As Decimal
Dim aRaise As Decimal
Dim perRaise As Decimal
Dim lifeEarn As Decimal
Dim finAsal As Decimal
Dim result As Integer
Dim nresult As Integer
Dim rb1 As String
Dim rb2 As String
Dim mfSex As String
Dim isNotNumeric As Boolean
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
firstN = CStr(TextBox1.Text)
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
intAge = CInt((Val(TextBox2.Text)))
If CBool(intAge) = isNotNumeric Then Label7.Text = "Error: Enter only numbers"
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
rb1 = "he"
rb1 = CStr(RadioButton1.Checked)
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
rb2 = "she"
rb2 = CStr(RadioButton2.Checked)
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
canSal = CDec(Val(TextBox3.Text))
If CBool(canSal) = isNotNumeric Then Label7.Text = "Error: Enter only numbers"
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
aRaise = CDec(Val(CDbl(TextBox4.Text) / 100))
If CBool(aRaise) = isNotNumeric Then Label7.Text = "Error: Enter only numbers"
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
retAge = CInt(Val(TextBox5.Text))
If CBool(retAge) = isNotNumeric Then Label7.Text = "Error: Enter only numbers"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
result = (retAge - intAge)
perRaise = (canSal * aRaise) + canSal
lifeEarn = (perRaise * result)
finAsal = (perRaise)
For perRaise = (canSal * aRaise) + canSal To result
For finAsal = (perRaise) To (aRaise * result)
If CBool(rb1) Then
mfSex = "his"
Else
If CBool(rb2) Then
mfSex = "her"
End If
End If
Next
Next
Label7.Text = ((firstN & " will earn " & FormatCurrency(lifeEarn) & " before retiring at age " & retAge & vbNewLine & " And " & mfSex & " final annual salary will be " & FormatCurrency(finAsal)))
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|