FourChargeClient.java


Below is the syntax highlighted version of FourChargeClient.java.


/*  Book Exercise 3.1.1 to create a Charge client */
public class FourChargeClient {
   public static void main(String[] args) {
      // read in distance r from command line
      double r = Double.parseDouble(args[0]);
      // center of standard drawing window
      double cx = 0.5;
      double cy = 0.5;

      // construct four charges
      Charge c1 = new Charge(cx + r, cy,     1.0);     // east
      Charge c2 =                                      // south
      Charge c3 =                                      // west
      Charge c4 =                                      // north

      // Compute potentials at (.25, .5)
      double px = 0.25;
      double py = 0.5;
      double v1 = c1.potentialAt(               );
      double v2 = 
      double v3 = 
      double v4 =

      // compute and output total potential
      double sum =                             
      System.out.println("total potential = " + sum);
   }
}