package main import ( "fmt" "io" "os" ) func main() { n1 := askNumber(os.Stdin) n2 := askNumber(os.Stdin) sum := add(n1, n2) printSum(os.Stdout, sum) } func add(n1, n2 float64) float64 { return n1 + n2 } func askNumber(in io.Reader) float64 { fmt.Println("Type a number:") n := 0.0 fmt.Fscanf(in, "%f\n", &n) return n } func printSum(out io.Writer, sum float64) { fmt.Fprintln(out, "The sum is:", sum) }