0
Argument2 return 0 when i call kn main this fonction should return the anglein degrees between the the two point a ,b
6 ответов
+ 1
I get the same output:
https://code.sololearn.com/cA7Q5L1193i5/?ref=app
+ 1
I guess your problem is your distance method. But is not your formula it is more a logical problem.
Lets say
Point a = 1,4
Point b = 3,1
You are calling b.argument2(a,b)
You jump into the distance method.
At first you calc distance(a) and then you calc distance(b)
Means first you calc the distance from a and b but then the distance from b and b, which is 0.
In the end your argument method calcs Math.toDegrees(Math.acos(3.61/0));
-> division by zero!
If you are calling a.argument(a,b) you calc Math.toDegress(Math.acos(0/3.61));
+ 1
You suppose you're right..thanks
0
Hello El mhadji Mohamed abdelhak
I removed your older question to avoid duplicates in q&a.
In line 34 and 36 remove }
I added a class Test:
public class Test{
public static void main(String[] args){
Point a = new Point("a", 1, 1);
Point b = new Point("b", 1, 4);
System.out.println(a.argument2(a,b));
System.out.println(b.argument2(a,b));
}
}
First output: 90.0
Second output: NaN (means not a number)
What is your expected output? And how do you get 0?
0
First point("a",1,4) second Point ("b",3,1) it is suppose to give me 90 also
0
The second should give me 90 but give me NaN why ?