Go language program to calculate parallelogram area

Views: 109   

Fallowing program shows you how to calculate parallelogram area.
This program gets parallelogram base and height from user and calculates area and prints it using following formula
Area = base X height

package main

import "fmt"

func main() {

  var parallelogramBase float64
  var parallelogramHeight float64
  var areaOfParallelogram float64
  fmt.Println("Please enter base of parallelogram:")
  fmt.Scanf("%f", &parallelogramBase)
  fmt.Println("Please enter height of parallelogram:")
  fmt.Scanf("%f", &parallelogramHeight)
  areaOfParallelogram = parallelogramBase * parallelogramHeight
  fmt.Println("Area of parallelogram is: " , areaOfParallelogram)
}

Output:

Please enter base of parallelogram:
 12
Please enter height of parallelogram:
 15
Area of parallelogram is:  180
On By