Check the following code with simple if else
blocks
cls
$a = Read-Host("Enter the marks ")
if (($a -le 100) -and ($a -ge 90)){
Write-Host("The grade is A")
}
elseif (($a -le 89) -and ($a -ge 80)){
Write-Host("The grade is B")
}
elseif (($a -le 79) -and ($a -ge 70)){
Write-Host("The grade is C")
}
elseif (($a -le 69) -and ($a -ge 60)){
Write-Host("The grade is D")
}
elseif($a -lt 60){
Write-Host("The grade is F")
}
And when I give input between 90 - 99
it returns without any output. And if I give 100
as input, I am getting "The grade is F"
, ie, the else
block is executed, but it should not work according to the code. Can anyone explain why?
Aucun commentaire:
Enregistrer un commentaire