Created
October 9, 2015 12:01
-
-
Save jarhoads/4bf36edf7f3d0b9c1e8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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