// class Programming - research on children interested in programming
package TestProgramming;
public class Programming {
private boolean [][] interest =
{{ true, true, true, true, true },
{ true, true, true, true, true },
{ false, false, false, false, false },
{ true, true, true, true, false },
{ true, true, true, true, true },
{ true, true, false, false,false },
{ true, true, true, true, true },
{ true, true, true, true, true }};
private char [] sexes = { 'B', 'G', 'B', 'G', 'B', 'G', 'B', 'G' };
private int [] math = { 85, 92, 86, 90, 94, 87, 75, 95 };
// check if for all the boys, or for all the girls, who were interested in programming
// through all the years, the last math grade was higher than 90.
public boolean checkGrade (char sex)
{
for ( int i=0; i< interest.length; i++)
{
if ( sexes [i] == sex )
{
int count = 0;
for ( int j=0; j diff )
{
diff = new_diff;
year = k;
}
}
return year;
}
}
// Test class Programming
package TestProgramming;
import javax.swing.*;
public class TestProgramming {
public static void main(String args[])
{
// create the object
Programming p = new Programming ();
// send message to object to check if for all the girls who were interested
// in programming through all the years, the last math grade was higher than 90.
boolean check = p.checkGrade('G');
if ( check )
JOptionPane.showMessageDialog(null, "The last math grade was higher than 90");
else
JOptionPane.showMessageDialog(null, "The last math grade was NOT higher than 90");
// send message to object to compute the year in which the difference between
// the number of boys and girls who were interested in programming was maximal.
JOptionPane.showMessageDialog(
null,"The year was "+ p.computeYear() );
System.exit (0);
}
}