Java x, y coordinates

Thread Starter

chrill3123

Joined Apr 21, 2010
9
Hi everyone:)

I have made a program that reads two coordinates (x, y) in double, and prints the coordinates to screen in format= (x, y), however this message comes when i try to compile=

C:\Java Program>javac PositionProg.java
PositionProg.java:7: cannot find symbol
symbol : variable x
location: class PositionProg
System.out.println(pos1.asString(x, y));
^
PositionProg.java:7: cannot find symbol
symbol : variable y
location: class PositionProg
System.out.println(pos1.asString(x, y));
^
2 errors

C:\Java Program>

Here is the code=

main program

public class PositionProg
{
public static void main(String[] argv)
{
Position pos1;
pos1 = new Position(25.17, 12.14);
System.out.println(pos1.asString(x, y));
}
}

the position class
class Position
{
public String a, b, c;
public double x, y;
public Position() //Constructor
{
x = 0.0;
y = 0.0;
}
public Position(double x, double y) //Constructor2
{
this.x = x;
this.y = y;
}
public String asString(Double x, Double y)
{
a = Double.toString(x);
b = Double.toString(y);
c = "("+a+","+b+")";
return c;
}
}

Please give some advice where I do wrong:).

Best regards Christian
 

Chieftain

Joined Feb 22, 2011
2
am not confirm about ans....but please check this link i think its helpful for u....
dreamincode . net / forums /topic/ 41671-x-y-coordinates/
 
Top