HELP with a plotter program ASAP!

I'm SUPER lost on this project and keep getting this error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

at Plotter.main(Plotter.java:3)

Here's the assingment:

Create a simple plotter (x-axis runs vertically, y -axis runs horizontally) using command line arguments for a (left end point), b (right end point), and n (number of sub-intervals of [a, b].)

Steps:

compute maximum and minimum values of the function on [a, b].

compute scaling factor sf. For example, does the following accomplish all we need?

sf = graphPageWidth/(max - min).

construct for each point in the interval the required number of spaces (one for each column) preceding the plot (an *)

#cols = sf ( f(a +idx) - min ).

and here's my code:public class Plotter {

public static void main(String[] args) {

double a = Double.parseDouble(args[0]);

double b = Double.parseDouble(args[1]);

double x, sf, y;

double max;

double min;

double nSpaces;

int n = Integer.parseInt(args[2]);

System.out.println(" "+args[0]+" "+args[1]+" "+args[2]);

double dx = (b-a)/n;

max=0;

min=0;

for (int i =0; i<=n; i++) {

x= a + i * dx;

y= x*x*x;

if (y>max) {

max=y;

}

else if (y<min) {

min=y;

}

}

sf = 120/(max - min);

System.out.println(dx);

System.out.println(max);

System.out.println(min);

for(int k=0; k<=n; k++) {

x = a + k * dx;

y = x*x*x;

nSpaces = (y - min) * sf;

int j = 0;

if(j<nSpaces)

{

System.out.print(" ");

j++;

}

else {

System.out.println("*");

}

}

}

}