Question problem with calculate

seamus123

New member
Joined
Dec 14, 2010
Messages
4
Location
Bristol, England
Programming Experience
3-5
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
 
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.
 
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
 
Back
Top