If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

filling a hexagon(very basic!)

Hey guys, I started learning Java a couple days ago, and my teacher gave me a assignment to make this hexagon that will stretch with the applet and such. I know that int's wont hold decimals but the doubles wont work either for some reason. Now this is the code I am using and the errors it gives are below:
public void paint(Graphics g) {
Graphics2D g2= (Graphics2D)g;
Polygon myPoly = new Polygon();
int a=(getWidth()/2);
int b=(int)a-10*Math.sqrt(3);
myPoly.addPoint(a,0);
myPoly.addPoint(b,10);
myPoly.addPoint(b,30);
g2.fill(myPoly);

and it gives me:
Possible loss of precision on the
int b=(int)a-10*Math.sqrt(3); line
please help me out, thanks in advanced

scratch that, this is the new code im using:
Graphics2D g2= (Graphics2D)g;
Polygon myPoly = new Polygon();
double a=(getWidth()/2);
double b=a-10*Math.sqrt(3);
double c=(getHeight());
double d=a+10*Math.sqrt(3);
myPoly.addPoint(a,0);
myPoly.addPoint(b,10);
myPoly.addPoint(b,c-10);
myPoly.addPoint(a,c);
myPoly.addPoint(d,c-10);
myPoly.addPoint(d,10);
g2.fill(myPoly);
And the Errors:
addpoint(int,int) in java.awt.Polygon cannot be applied to (double,int)
and it goes on like that for each point i plotted, what am I doing wrong?