Results 1 to 4 of 4

Thread: problem with calculate

  1. #1
    seamus123 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0
    Join Date
    Dec 2010
    Location
    Bristol, England
    Posts
    4
    Reputation
    0

    Question problem with calculate

    im doing a VB project for my A-level and i have got stuck on some code.
    it has to caluclulate the amount a person gets payed when they are being made redundent depending on their age (i used the date of birth to do this), years servered and their weeks pay

    e.g. if i started work in 1980 and i was born in 1960 and my weekly pay was 400 i would get 0.5 x weeks under age of 22: 1 x weeks over age of 22 and under age of 41: and finally 1.5 x weeks over 41
    my pay would be ( (2x0.5) + (19x1) + (9x1.5)) x 400 = 13400

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,334
    Reputation
    1543
    As always, divide and conquer. Forget programming for a moment. Take a pen and paper and write down the steps that you need to perform to complete the calculation manually. Once you have those steps, start with the first and forget the rest for the moment. Write some pseudo-code for that step, then convert that into actual VB code. Once that's done, move onto the next step.

    You've provided a written calculation so you must know what the algorithm is, so write down. Make sure that you have broken it down into the simplest form possible. Only when you've done that should you consider writing code and only then can you say that you're stuck, and then only on one specific step.

  3. #3
    seamus123 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0
    Join Date
    Dec 2010
    Location
    Bristol, England
    Posts
    4
    Reputation
    0
    X = DoB + 22(years)
    Y = X - start date
    if Y < 0 then
    A = 0
    else
    A = 0.5 * Y
    end if

    X = DoB + 41(years) (DoB = date of birth)
    Z = X - start date
    Q = Z - Y
    if Q < 0 then
    B = 0
    else
    B = 1 * Y
    end if

    X = DoB + 65(years)
    U = X - start date
    V = X - now
    W = U - V
    I = W - z
    if I < 0 then
    C = 0
    else
    C = 1.5 * Y
    end if

    T = A + B + C
    P = T x week pay
    output P

    this is what i have at the moment the first part works i think but the second and third part don't, which i don't understand

  4. #4
    seamus123 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.0
    Join Date
    Dec 2010
    Location
    Bristol, England
    Posts
    4
    Reputation
    0
    no need for any help now i have fixed it

Bookmarks

Posting Permissions

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