UNB/ CS/ David Bremner/ teaching/ java/ BarGraph.java
import ccj.*;

public class BarGraph extends GraphicsApplet
{  public void run()
   {  int n = readInt
         ("How many employees are in your company?");
      Employee[] staff = new Employee[n];
      int i;
      for(i = 0; i < staff.length; i++)
      {  String name = readString("Employee name:");
         double salary = readDouble("Salary:");
         staff[i] = new Employee(name, salary);
      }

      Employee highestPaid = staff[0];
      for (i = 1; i < staff.length; i++)
         if (staff[i].getSalary() > highestPaid.getSalary())
            highestPaid = staff[i];

      setCoord(0, highestPaid.getSalary(), staff.length, 0);
      for (i = 0; i < staff.length; i++)
      {  Line bar = new Line(new Point(i, 0),
            new Point(i, staff[i].getSalary()));
         Message s = new Message(bar.getEnd(),
            staff[i].getName());
         bar.draw();
         s.draw();
      }
   }
}