Two mathematics teachers give the same test to each of their classes. The marks for the 30 students in each class are given below.
| Teacher A | Teacher B |
| 38, 70, 34, 59, 49, 42, 46, 74, 68, 54, 56, 57, 59, 60, 55, 65, 61, 47, 60, 61, 50, 48, 55, 51, 36, 28, 50, 62, 55, 40 | 60, 78, 85, 58, 70, 55, 68, 79, 81, 68, 48, 59, 64, 74, 88, 81, 82, 80, 69, 77, 76, 78, 72, 73, 65, 64, 90, 53, 73, 80 |
Compare the data for the two teachers.
What does this data tell you about the teachers? Print out your results on the screen.
public class compare
{
public static void main (String args [])
{
new compare ();
}
public compare ()
{
int classA [] = {38, 70, 34, 59, 49, 42, 46, 74, 68, 54, 56, 57, 59, 60, 55, 65, 61, 47, 60, 61, 50, 48, 55, 51, 36, 28, 50, 62, 55, 40};
int classB [] = {60, 78, 85, 58, 70, 55, 68, 79, 81, 68, 48, 59, 64, 74, 88, 81, 82, 80, 69, 77, 76, 78, 72, 73, 65, 64, 90, 53, 73, 80};
}
//called like this: bubble(classA) or bubble(classB)
public void bubble (int a [])
{ //Pre: a is an array with values. It is of size n
//Post: the values in a are put in ascending order
int n = a.length;
int temp;
for (int i = 0 ; i < n - 1 ; i++)
{
for (int j = 0 ; j < n - 1 - i ; j++)
{ // compare the two neighbours
if (a [j + 1] > a [j])
{ //swap the neighbours if necessary
temp = a [j];
a [j] = a [j + 1];
a [j + 1] = temp;
}
}
}
}
}