Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- var figure string
- fmt.Scanln(&figure)
- var area = 0.0
- if (figure == "square") {
- var side float64
- fmt.Scanln(&side)
- area = side * side
- } else if (figure == "rectangle") {
- var base, height float64
- fmt.Scanln(&base)
- fmt.Scanln(&height)
- area = base * height
- } else if (figure == "circle") {
- var radius float64
- fmt.Scanln(&radius)
- area = math.Pi * radius * radius
- } else if (figure == "triangle") {
- var base, height float64
- fmt.Scanln(&base)
- fmt.Scanln(&height)
- area = base * height / 2
- }
- fmt.Println(area)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement