Round up round down (1 Viewer)

BobNTN

Registered User.
Local time
Today, 03:19
Joined
Jan 23, 2008
Messages
308
Working on a golf points (instead of stroke) calculator. I have run into a brick wall on trying to:
Scenario: If I need 20 points on a given round and I pull 23, I am plus 3. I need to round that plus 3 up to 4, take half and add to the 20 needed which will make the next round needed 22. On an even number, I would just take half and add to the points.
Where I am really lost is incorporating minus numbers.
In that scenario, if I only pull 18, then it would be half the minus 2 from 20 leaving 19 next round. If I am minus an odd number, say minus 3, we don’t round up, we round down which would be 1.
In summary, any plus number round up if odd, and divide by two. If minus odd number, I guess round ‘down’ and divide by two.
I am trying to create a query that will account for both but haven’t the foggiest how to do that. Appreciate any help / guidance.
 

NickHa

CITP
Local time
Today, 08:19
Joined
Jan 29, 2012
Messages
203
Something like this may do what you want?
Code:
Dim intActualScore  As Integer, intResultantScore As Integer, intTargetScore As Integer
intTargetScore = 20
intActualScore = 22
intResultantScore = intTargetScore + (((intActualScore + (intActualScore Mod 2)) - intTargetScore) / 2)
I tried this with some values for intActualScore above and below intTargetScore (20) and the results appear to be consistent with what you want.
 

BobNTN

Registered User.
Local time
Today, 03:19
Joined
Jan 23, 2008
Messages
308
This is what I have tried and as nearest I can get.

Code:
SELECT tblpoints.frineed, tblpoints.fripull, IIf([fripull]<[frineed],[frineed]-Int(([frineed]-[fripull])/2),IIf([fripull]>[frineed],[frineed]+Int(([fripull]-[frineed])/2),[fripull])) AS satneed, Switch([fripull]<[frineed],[frineed]-Int(([frineed]-[fripull])/2),[fripull]>[frineed],[frineed]+Int(([fripull]-[frineed])/2),True,[fripull]) AS Satneed2, IIf([satneed]="odd",Int([satneed]+1),[satneed]) AS rndup, IIf(Int([fripull]-[frineed])>3,4,Int(([fripull]-[frineed]))) AS restrictup, IIf([restrictup]<-3,-4,[restrictup]) AS restrictdwn
FROM tblpoints;
I also forgot two factors. The above would be to adjust points each day for the individual. However, I need to also adjust for the team (2 man) where no player can hurt nor help a team more than 4 points per round.
As you can see I tried to do that in the query.
Someone on here helped me a few years ago but I sort of abandoned it and now am trying to finish it.

Let me try to explain it better.

We have a 3 day tournament - Friday, Saturday, Sunday each year.
It is comprised of 2 person teams. Usually around 70 to 80 players total.
Player gets 1 point for bogey, 2 for par, 3 for birdie, etc.
Each player starts Friday with a needed points based on the last year's Sunday round (points needed vs points pulled).
Each player's points are adjusted for the next day based on HALF of his plus or minus for the previous day, rounded up on plus but rounded down for minus.
However, in adding to his partner's score, he can not help nor hurt the team score more than 4 points.
What I am trying to incorporate in my program is to be able to input scores each day as players turn their score cards in, program gives next day 'needed points, and teams' total score. Of course I am doing other averaging and things.
Then, next year, I will have the first day points (Friday) needed for each player.
 
Last edited:

Users who are viewing this thread

Top Bottom