package wind07.gpacalculator;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;

import java.util.Locale;

import static wind07.gpacalculator.MainActivity.modList;

public class GPA extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gpa);
        Intent intent = getIntent();

        TextView lblGPA = (TextView) findViewById(R.id.lblGPA);

        double gradepoint = 0.0;
        double sumcredxgradepoint = 0.0;
        double sumcreditpoint = 0.0;
        double gpa = 0.0;

        for (int i = 0 ; i < modList.size() ; i++){
            if (modList.get(i).grade.equals("AD/A+/A"))
                gradepoint = 4;
            else if (modList.get(i).grade.equals("B+"))
                gradepoint = 3.5;
            else if (modList.get(i).grade.equals("B"))
                gradepoint = 3;
            else if (modList.get(i).grade.equals("C+"))
                gradepoint = 2.5;
            else if (modList.get(i).grade.equals("C"))
                gradepoint = 2;
            else if (modList.get(i).grade.equals("D+"))
                gradepoint = 1.5;
            else if (modList.get(i).grade.equals("D"))
                gradepoint = 1;
            else if (modList.get(i).grade.equals("F"))
                gradepoint = 0;
            sumcredxgradepoint += modList.get(i).credUnits * gradepoint;
            sumcreditpoint += modList.get(i).credUnits;
        }
        gpa = sumcredxgradepoint/sumcreditpoint;
        String gpaRounded = String.format(Locale.ENGLISH,"%.2f", gpa);
        lblGPA.setText(gpaRounded);

    }
}

@@ -788,16 +788,17 @@
 ; i++)%7B%0A
+%0A
         
@@ -801,18 +801,22 @@
         
-if
+switch
  (modLis
@@ -829,24 +829,40 @@
 i).grade
-.equals(
+)%7B%0A                case 
 %22AD/A+/A
@@ -862,19 +862,22 @@
 AD/A+/A%22
-))%0A
+:%0A    
         
@@ -916,406 +916,416 @@
     
-else if (modList.get(i).grade.equals(%22B+%22))%0A                gradepoint = 3.5;%0A            else if (modList.get(i).grade.equals(%22B%22))%0A                gradepoint = 3;%0A            else if (modList.get(i).grade.equals(%22C+%22))%0A                gradepoint = 2.5;%0A            else if (modList.get(i).grade.equals(%22C%22))%0A                gradepoint = 2;%0A            else if (modList.get(i).grade.equals(%22D+%22))%0A
+        break;%0A                case %22B+%22:%0A                    gradepoint = 3.5;%0A                    break;%0A                case %22B%22:%0A                    gradepoint = 3;%0A                    break;%0A                case %22C+%22:%0A                    gradepoint = 2.5;%0A                    break;%0A                case %22C%22:%0A                    gradepoint = 2;%0A                    break;%0A                case %22D+%22:%0A    
     
@@ -1370,51 +1370,53 @@
     
-else if (modList.get(i).grade.equals(%22D%22))%0A
+        break;%0A                case %22F%22:%0A    
     
@@ -1440,17 +1440,17 @@
 point = 
-1
+0
 ;%0A      
@@ -1459,82 +1459,36 @@
     
-else if (modList.get(i).grade.equals(%22F%22))%0A                gradepoint = 0;
+        break;%0A            %7D
 %0A   

Use switch case to determine credit grade point