add chapter 4

This commit is contained in:
Archie Fox
2025-01-30 12:01:02 +03:00
parent 36a52e353d
commit ecc1e28f0a
8 changed files with 129 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package keyboard
import (
"bufio"
"os"
"strconv"
"strings"
)
func GetFloat() (float64, error) {
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
return 0, err
}
input = strings.TrimSpace(input)
number, err := strconv.ParseFloat(input, 64)
if err != nil {
return 0, err
}
return number, nil
}