// NOT DREWS SOLUTION BUT YOU CAN USED IT AS ANOTHER EXAMPLE package main import ( "fmt" "math" "strconv" ) func GenDisplaceFn(acceleration, initialVelocity, initialDisplacement float64) func(float64) float64 { calcDisplace := func(time float64) float64 { return 0.5*acceleration*math.Pow(time, 2) + initialVelocity*time + initialDisplacement } return calcDisplace } func main() { var ( acceleration float64 initialVelocity float64 initialDisplacement float64 time float64 inputAcc string inputVel string inputDisp string inputTime string ) fmt.Printf("Please enter acceleration\n") _, _ = fmt.Scanln(&inputAcc) inputAcceralation, _ := strconv.Atoi(inputAcc) acceleration = float64(inputAcceralation) fmt.Printf("Please enter Velocity\n") _, _ = fmt.Scan(&inputVel) inputVelocity, _ := strconv.Atoi(inputVel) initialVelocity = float64(inputVelocity) fmt.Printf("Please enter Displacement\n") _, _ = fmt.Scan(&inputDisp) inputDisplacement, _ := strconv.Atoi(inputDisp) initialDisplacement = float64(inputDisplacement) fmt.Printf("Please enter time\n") _, _ = fmt.Scan(&inputTime) inputtime, _ := strconv.Atoi(inputTime) time = float64(inputtime) fn := GenDisplaceFn(acceleration, initialVelocity, initialDisplacement) fmt.Println(fn(time)) }