I am working on a Fluid Mechanics problem and I decided to solve the problem using Java instead of excel because I just wanted the experience. I have been stuck on this one part for the past 4 hours though. I have an array I made in one class and I need to get all that data over to another class so that I can graph it. At this point I am really just looking for the answer. My mind is shot right now and I just want to get this done with.
I have found others with similar problems, but I can not make sense of the solutions that they were given and right now my brain is fried, which is why I would prefer if someone were able to just show me exactly what to type, but any help is appreciated.
public class Eight_c {
public static void main(String [] args) {
Eight_c ball = new Eight_c();
...
int count = 0;
double[] y = new double[101];
double[] x = new double[101];
// Calculates the Distance the ball has traveled using increments of .1s
for(double t = 0; t<=time; t=t+.1) {
y[count] = t;
x[count] = d;
V1 = ball.Velocity(a, V2, dt);
Fd = ball.Drag_Force(V2);
a = ball.Acceleration(Fd, m);
d = ball.Distance(V2, a, dt) + d;
...
Above is where I have created the two arrays, x and y.
Below is where they need to go.
public class Graph {
public static void main(String [] args) {
double [] x;
double [] y;
// create your PlotPanel (you can use it as a JPanel)
Plot2DPanel plot = new Plot2DPanel();
// add a line plot to the PlotPanel
plot.addLinePlot("Distance vs Time", x, y);
// put the PlotPanel in a JFrame, as a JPanel
JFrame frame = new JFrame("a plot panel");
frame.setContentPane(plot);
frame.setVisible(true);
}
}