mercredi 28 septembre 2016

Nested IF...THEN...ELSE in GW-BASIC

I use following block of code to test some conditions in gw-basic program.

IF Average >= 80 AND Average <= 100 THEN Grade$ = "A"
IF Average >= 70 AND Average <= 79 THEN Grade$ = "B"
IF Average >= 60 AND Average <= 69 THEN Grade$ = "C"
IF Average >= 50 AND Average <= 59 THEN Grade$ = "D"
IF Average >= 40 AND Average <= 49 THEN Grade$ = "E" ELSE Grade$ = "F"  
PRINT "Average is: ", Average
PRINT "Grade is: ", Grade$

It always prints Grade is: F whatever is the value of Àverage.

What is the error in this gw-basic program?

Aucun commentaire:

Enregistrer un commentaire