📜  F#如果Elif梯子

📅  最后修改于: 2021-01-01 04:42:07             🧑  作者: Mango

F#If-Elif梯子

F#if-elif梯形图仅从多个布尔表达式中执行一个布尔表达式。

if boolean-expression then 
    expression1 
elif boolean-expression then
    expression2 
elif Boolean-expression then
     expression3

示例:if- then elif梯子

open System   // System is a package, and this is the way to import package in F#
Console.Write("Enter integer number to check whether it is even or not : ")
let input = Console.ReadLine()
let number = input |> Int32.Parse   // casting input to integer value
if(number<0 && number>100) then
printfn "wrong number"
elif(number>=0 && number<50) then
printfn "fail"
elif(number>=50 && number<60)then
printfn "D Grade"
elif(number>=60 && number<70) then
printfn "C Grade"
elif(number>=70 && number<80)then
printfn "B Grade"
elif(number>=80 && number<90)then
printfn "A Grade"
elif(number>=90 && number<=100)then
printfn "A+ Grade"

输出:

Enter a number to check grade: 85
A Grade