Calculating the student grade using functions
//Creating and storing a variable
var percentage:Float = 100
//Creating a function for grades
func grades()
{
//if condition to check student grades
if (percentage >= 70 && percentage <= 100)
{
print("Congratulations! you got First class with Distinction")
}
else if (percentage >= 60 && percentage < 70)
{
print("Congratulations! you got First class")
}
else if (percentage >= 50 && percentage < 60)
{
print("Congratulations! you got Second class")
}
else if (percentage >= 35 && percentage < 50)
{
print("Congratulations! you got Compartmental class")
}
}
No comments:
Post a Comment