- #1
CAF123
Gold Member
- 2,948
- 88
Homework Statement
See code below:
The Attempt at a Solution
I am simply trying to get the code to work: When I try to compile, the terminal says that apparently the package ptolemy.plot.* package does not exist and so does not recognise statements like PlotFrame etc.. Why is this?
Code:
import java.io.Console;
import java.io.*;
import java.lang.Math;
import java.lang.Boolean;
import ptolemy.plot.*;
public class Edisc {
public static void main (String args[]) {
Console.myConsole = System.console();
Plot disc = new Plot();
disc.setTitle("Graph of the axial E field from a charged disc");
disc.setXLabel("distance along z");
disc.setYLabel("E field");
PlotFrame myFrame = new PlotFrame("E vs z", disc);
myFrame.setSize(800,600);
int dataSet = 0;
double q = 6.0e-9;
double R = 10;
double eps = 8.85e-12;
int points = 100;
double E[] = new double[points];
double z[] = new double[points];
for(int i = 0; i < (points-1); i++) {
z[i] = (100*(int)i/points);
double Eqn = q*((2*(Math.PI())*eps*(Math.pow(R,2))))^(-1)*(1 - z[i]*((Math.sqrt((Math.pow(R,2)) + (Math.pow(z[i],2))))))^(-1);
disc.addPoint(dataSet, z[i], Eqn, true);
myFrame.setVisible(true);
}
}
}