Results 1 to 4 of 4

Thread: Help with a Pay Calculator

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2010
    Posts
    37

    Help with a Pay Calculator

    i have two texts boxes where the user can enter pay per hour and expected raise % per year.

    when the calculate button is clicked it calculates yearly base on a 40 hour and 52 week base. the raise increases each amount after the first year and does it for the next ten years. yearly amount is displayed for the next ten years.

    I need some help getting this going!! Thanks

  2. #2
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Help with a Pay Calculator

    Post what you have so far. We can help you out when we see where specifically you're having problems.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2010
    Posts
    37

    Re: Help with a Pay Calculator

    im not sure how to do the interest part for the next ten years. I have a textbox where they can enter interest.

    Dim PerHour As Decimal

    PerHour = Decimal.Parse(PerHrTextBox.Text)

    If Decimal.Parse(PerHrTextBox.Text) > 0 Then 'Successful Conversion
    PerYrTextBox.Text = (PerHour * 40) * 52
    End If

  4. #4
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: Help with a Pay Calculator

    Ok, well, make three variable to hold our calculated total, raise percent and current per-hour wage:

    Code:
    Dim total As Decimal
    Dim currentPerHour As Decimal
    Dim raise As Decimal
    Next, set the currentPerHour = your initial value. Decimal.Parse is a good way to do it, but Decimal.TryParse is even better, lets set both the currentPerHour and the raise amount:

    Code:
    If Decimal.TryParse(PerHrTextBox.Text, currentPerHour) AndAlso Decimal.TryParse(RaiseTextBox.Text, raise) Then
    Now, add the first years wages to your total:

    Code:
    total += currentPerHour * 2080
    Next, increase the currentPerHour by the % raise (we want to add 1 because our raise is a percent in addition to 100% of the pay) :
    Code:
    currentPerHour *= (1 + raise)
    Now, we need to repeat these two commands, so enclose them both in a loop; for 10 years, I need to loop 10 times:
    Code:
    For i As Integer = 1 To 10
    ..
    ..
    Next
    Finally, display your result:
    Code:
    MessageBox.Show(String.Format("The result is: {0}", total))
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width