-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (27 loc) · 979 Bytes
/
Copy pathmain.go
File metadata and controls
34 lines (27 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"flag"
"fmt"
"math"
)
// Handicap Differential
//
// (adjusted gross score minus course rating) times (113 divided by slope rating)
//
// (score - cr) * (113 / sr)
// (83-72.6) * (113/135)
const standardSlope = 113
// presidio (72.6/135), metro (73.5/129), harding(72.7/125), corica (73/128), peacock (69.9/125)
func main() {
score := flag.Float64("s", 0.0, "adjusted gross score")
courseRating := flag.Float64("cr", 72.6, "course rating")
slopeRating := flag.Float64("sr", 135.0, "slope rating")
flag.Parse()
differential := (*score - *courseRating) * (standardSlope / *slopeRating)
fmt.Printf("Score: %v\n", int(*score))
fmt.Printf("Course Rating: %v\n", *courseRating)
fmt.Printf("Slope Rating: %v\n", int(*slopeRating))
// little hack or go quark to get rounding to the tenth place
// https://stackoverflow.com/questions/52048218/round-all-decimal-points-in-golang
fmt.Printf("Differential: %v\n", math.Round(differential*10)/10)
}