Go 程序:计算立方体的体积和表面积

编写一个 Go 程序来计算立方体的体积和表面积。计算立方体体积、表面积和侧面积的数学公式是:

  • 立方体表面积 = 6l² (l = 立方体任意边的长度)。
  • 立方体体积 = l * l * l
  • 立方体的侧面积 = 4 * (l * l)
package main

import "fmt"

func main() {

    var cblen, cbSA, cbVolume, cbLA float32

    fmt.Print("Enter the Length of any Side of a Cube = ")
    fmt.Scanln(&cblen)

    cbSA = 6 * (cblen * cblen)
    cbVolume = cblen * cblen * cblen
    cbLA = 4 * (cblen * cblen)

    fmt.Println("\nThe Volume of a Cube            = ", cbVolume)
    fmt.Println("The Surface Area of a Cube      = ", cbSA)
    fmt.Println("Lateral Surface Area of a Cube  = ", cbLA)
}
Go program to Find Volume and Surface Area of a Cube