0
double deltaX;
deltaX = X2-X1;
double deltaY;
deltaY = Y2-Y1;
double dis;
dis=Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
double kilometers;
kilometers = dis*1.609344;
int kilometersInt;
kilometersInt=(int)this.kilometers;
System.out.println(kilometersInt);

I am doing an online AP Computer Science course through AP4ALL and I have to write the code to calculate the distance between two points. This is the final step of the code where I have to convert my answer from miles to kilometers using integer math. It is coming up with one error that says it "cannot find symbol - variable kilometers" even though I declared it. How do I fix this problem?

B.Rob
  • 1
  • 2

0 Answers0