Advertisement
Guest User

aaaaaaaaaaaaa

a guest
Sep 25th, 2021
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.63 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "bufio"
  5.     "fmt"
  6.     "math"
  7.     "os"
  8.     "strconv"
  9.     "strings"
  10.     //  "errors"
  11. )
  12.  
  13. func main() {
  14.     phrase := "Counting the circles..." //string
  15.  
  16.     fmt.Println(phrase)
  17.     fmt.Println("Please select a radius for a circle")
  18.     reader := bufio.NewReader(os.Stdin)
  19.     rad, _ := reader.ReadString('\n')
  20.     rad = strings.Replace(rad, "\n", "", -1)
  21.     numrad, e := strconv.ParseFloat(rad, 64)
  22.     if e != nil {
  23.         fmt.Println("Conversion error", rad)
  24.     }
  25.     circlearea(numrad)
  26.  
  27. }
  28.  
  29. func circlearea(p float64) {
  30.     area := (math.Pow(p, 2)) * math.Pi
  31.     var printable string = strconv.FormatFloat(area, 'f', 6, 64)
  32.     fmt.Println(printable)
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement