Calculating the volume of a Cylinder

Report a typo

Patrick ⭐️ really likes mayonnaise! He wants to calculate the volume of a mayonnaise tub using the formula of the volume of a cylinder.

Can you help Patrick create a Go program that takes as an input the radius and the height of a cylinder, then calculates and prints its volume using the following formula:

hight radius^2 pi

Please print the calculated volume using two decimals with the "%.2f" verb!

Sample Input 1:

3
4

Sample Output 1:

113.10
Write a program in Go
package main

import (
"fmt"
"math"
)

func main() {
var radius float64
fmt.Scanln(&radius)

var height float64
fmt.Scanln(&height)

// Using the functions from the math package create the formula
// to calculate the volume of a cylinder below:
volume := ?

fmt.Printf("%.2f", volume)
}
___

Create a free account to access the full topic