Skip to content

Instantly share code, notes, and snippets.

@jarhoads
Created October 9, 2015 12:01
Show Gist options
  • Save jarhoads/4bf36edf7f3d0b9c1e8d to your computer and use it in GitHub Desktop.
Save jarhoads/4bf36edf7f3d0b9c1e8d to your computer and use it in GitHub Desktop.
open System
// I'm creating two functions: cylinderVolumeEdx and cylinderVolumePrecise
// this is because the definition of the formula in the Edx assignment is
// both incorrect (should be PI*r^2*h) and uses a rounded version of PI(3.14)
// this version will give you the correct answer for the assignment
let cylinderVolumeEdx (r:float) (h:float) = 2.0 * 3.14 * r * r * h
let cylinderVolumePrecise (r:float) (h:float) = Math.PI * Math.Pow(r,2.0) * h
[<EntryPoint>]
let main argv =
printfn "Enter the radius : "
let radius = Console.ReadLine()
let f_radius = float radius
printfn "Enter the height : "
let height = Console.ReadLine()
let f_height = float height
let volume_edx = cylinderVolumeEdx f_radius f_height
let volume_precise = cylinderVolumePrecise f_radius f_height
printfn "Volume of the cylinder for Edx Assignment : %f" volume_edx
printfn "Volume of the cylinder (correct) : %f" volume_precise
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment