SECJ1013-02 Programming Technique I

Grades

Introduction

                 grade.jpg   grade switch.jpg

                    Figure 1: If else statement                      Figure 2: Switch statement

 

From the figures above, it shows that if else statement could be replaced with switch statement. 

For example, when the marks is between 90 to 100, it will execute the grade A+ and break out of the switch. If not, it will continue with the following marks etc.

 

File(s) to download