One solution is to actually use an integer array instead of separate test
strings:
You could loop parse the response from JOptionPane.showInputDialog
into the individual elements of the array.
Arrays.sort
could be used to sort them to allow you to pick out the 2 highest values.
The average can be easily calculated then by adding these 2 values & dividing by 2.
int[] testScore = new int[3];
for (int i = 0; i < testScore.length; i++) {
testScore[i] = Integer.parseInt(JOptionPane.showInputDialog("Please input mark for test " + i + ": "));
}
Arrays.sort(testScore);
System.out.println("Average: " + (testScore[1] + testScore[2])/2.0);