package main
import (
"fmt"
"bufio"
"os"
"strconv"
"math"
)
func main() {
var inpA = bufio.NewScanner(os.Stdin)
var inpB = bufio.NewScanner(os.Stdin)
var inpC = bufio.NewScanner(os.Stdin)
fmt.Print("input A value: ")
inpA.Scan()
fmt.Print("input B value: ")
inpB.Scan()
fmt.Print("input C value: ")
inpC.Scan()
cal(inpA.Text(),inpB.Text(),inpC.Text())
}
func cal(INP1, INP2, INP3) string{
b := INP2
a := INP1
c := INP3
e := 4
la := 2
a2 := float64(e)*float64(a)
b2 := float64(b*b)
ac := float64(e)*float64(a)*float64(c)
q := math.Sqrt(math.Abs(b2-ac))
x := q/a2
Rx := x
fmt.Print("x = " + strconv.Itoa(Rx))
}
What am I doing wrong? I All I want to do is pass the input into func cal. Also I am having problems with printing Rx. Because it is a float. So how do I change x/RX to a non float?
Has @JimB already pointed out func cal is not having type for parameters. In addition it has other issues to like:
Look at this updated function:
func cal(INP1, INP2, INP3 string) string{
b,_ := strconv.ParseFloat(INP2, 64)
a,_ := strconv.ParseFloat(INP1, 64)
c,_ := strconv.ParseFloat(INP3, 64)
e := 4
la := 2
a2 := float64(e)*float64(a)
b2 := float64(b*b)
ac := float64(e)*float64(a)*float64(c)
q := math.Sqrt(math.Abs(b2-ac))
x := q/a2
Rx := x
fmt.Print("x = " + strconv.FormatFloat(Rx, 'f', 6, 64))
fmt.Print(la)
return "return value"
}
For now I have used la, by printing it.