Created
April 15, 2010 10:15
-
-
Save rtipton/366942 to your computer and use it in GitHub Desktop.
F# -- Calculate Max Heartrate based on age input
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
// Calculates the maximum heartrate based on the age input by the user | |
(* Strings in F# are by default, immutable. If you want the string to change | |
in any way [ie, assigning values, concantination, etc] you must make the | |
variables mutable. *) | |
open System | |
let main() = | |
let mutable maxHR = 0 | |
let mutable entries = 0 | |
let mutable age = String.Empty | |
while entries < 5 do | |
Console.Write("Enter your age: ") | |
entries <- entries + 1 | |
age <- Console.ReadLine() | |
maxHR <- 220 - Int32.Parse(age) | |
Console.WriteLine("Your Max Heartrate is " + maxHR.ToString()) | |
Console.ReadKey(true) |> ignore | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment