Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: circle STDIN

package main

import (
	"fmt"
	"strconv"
)

func main() {
	pi := 3.14

	var radiusStr string
	fmt.Print("radius: ")
	fmt.Scan(&radiusStr)

	radius, err := strconv.ParseFloat(radiusStr, 64)
	if err == nil {
		fmt.Println(radius)
		area := pi * radius * radius
		circumference := 2 * pi * radius
		fmt.Printf("Area: %v\n", area)
		fmt.Printf("Cirumference: %v\n", circumference)
	}
}