Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "math"
- "os"
- "strconv"
- "strings"
- // "errors"
- )
- func main() {
- phrase := "Counting the circles..." //string
- fmt.Println(phrase)
- fmt.Println("Please select a radius for a circle")
- reader := bufio.NewReader(os.Stdin)
- rad, _ := reader.ReadString('\n')
- rad = strings.Replace(rad, "\n", "", -1)
- numrad, e := strconv.ParseFloat(rad, 64)
- if e != nil {
- fmt.Println("Conversion error", rad)
- }
- circlearea(numrad)
- }
- func circlearea(p float64) {
- area := (math.Pow(p, 2)) * math.Pi
- var printable string = strconv.FormatFloat(area, 'f', 6, 64)
- fmt.Println(printable)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement