Q:

ArrayList computation? 

How can I add the units he/she enrolled every time the user inputs the code he/she wants to enroll?  Is there any way I can add the units every time he/she enroll using arrayList? 
   int units = 3 
    arrList.add("A25"+"\t\tCS 212"+"\t\tData Structures\t\t\t\t"+ units);
    arrList.add("A26"+"\t\tIT 312"+"\t\tData Base Management System 2\t\t"+ units);
    arrList.add("A27"+"\t\tIT 312"+"\t\tData Base Management System 2\t\t"+ units);

  System.out.println("\n\t\tCodes to enroll");
   for(int i = 0; i < 3; i++,num++)
    {   
       codeNo[i] = scan.next();
    }
   for (String s : arrList) {

            for(int i =0; i < codeNo.length; i++)

                  if (s.startsWith(codeNo[i])) {

                    System.out.println("\t\t\t"+s);

                  /**
                   *  this is what I tried
                   * units = units + units;
                   */
                  } 

            }
     tuitionFee = ( tuitionFee * units  + miscFee )  / 3;

        System.out.println("\n\n\t\tTOTAL FEE: ");
        System.out.printf("\t\tPrelims: "+"%.2f",tuitionFee);
        System.out.printf("\t\tMidTerm: "+"%.2f",tuitionFee);
        System.out.printf("\t\tFinals: "+"%.2f",tuitionFee);

A:

HashMap<String,Integer> mapCodeToUnit = new HashMap<String,Integer>();
mapCodeToUnit.put("A25", 3);
mapCodeToUnit.put("A26", 3);
mapCodeToUnit.put("A27", 3);

arrList.add("A25"+"\t\tCS 212"+"\t\tData Structures\t\t\t\t"+ mapCodeToUnit.get("A25"));
arrList.add("A26"+"\t\tIT 312"+"\t\tData Base Management System 2\t\t"+ mapCodeToUnit.get("A26"));
arrList.add("A27"+"\t\tIT 312"+"\t\tData Base Management System 2\t\t"+ mapCodeToUnit.get("A27"));

System.out.println("\n\t\tCodes to enroll");
String codeNo[] = new String[3];
for(int i = 0; i < 3; i++,num++)
{   
    codeNo[i] = scan.next();
}

int totalNumberOfUnit = 0;
for(int i =0; i < codeNo.length; i++) {
   totalNumberOfUnit += mapCodeToUnit.get(codeNo[i]);
}

tuitionFee = ( tuitionFee * totalNumberOfUnit  + miscFee )  / 3;

