samedi 2 juin 2018

Data Structure to be used for mapping a range of grades to each Gradepoint

Table representing the Mark Range to be mapped to GPA

Currently, I have used a if-else statement to map the ranges to each gradepoint. That took up about 70-80 lines of code. I was wondering if there was a better way to represent this data through data structures/algorithms. (Hashtables, Linked List etc)

if (score>=98.1) {
        gpa = 4.0;
} else if(score<=98 && score>=96.1) {
        gpa = 3.9;
} else if (...){...}

The above is a one line sample of what I have done so far in terms of code.

Aucun commentaire:

Enregistrer un commentaire