Skip to content

Commit

Permalink
update c2-m2
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangbits committed Jun 4, 2020
1 parent b175a2f commit 457d55e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions c2-m2/displacement-calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ package main

import "fmt"

//fn := GenDisplaceFn(10, 2, 1)
// fmt.Println(fn(3))
// fmt.Println(fn(5))

func main() {
fn := GenDisplaceFn(10, 2, 0)
fmt.Println(fn(3))
fmt.Println(fn(5))
var d, v, s0, time float64
fmt.Printf("Enter intial acceleration:\n")
fmt.Scan(&d)
fmt.Printf("Enter initial Velocity:\n")
fmt.Scan(&v)
fmt.Printf("Enter initial Displacement:\n")
fmt.Scan(&s0)
fn := GenDisplaceFn(d, v, s0)
fmt.Printf("Enter Time:\n")
fmt.Scan(&time)
fmt.Println("Displacement value:", fn(time))
}

// GenDisplaceFn forming a function with initial value except time of displace formulation
Expand Down

0 comments on commit 457d55e

Please sign in to comment.