Argument2 return 0 when i call kn main this fonction should return the anglein degrees between the the two point a ,b | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Argument2 return 0 when i call kn main this fonction should return the anglein degrees between the the two point a ,b

https://code.sololearn.com/cQl8tY1kYg0k/?ref=app

13th Mar 2021, 9:36 PM
El mhadji Mohamed abdelhak
El mhadji Mohamed abdelhak - avatar
6 Answers
13th Mar 2021, 10:11 PM
Denise Roßberg
Denise Roßberg - avatar
+ 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));
13th Mar 2021, 11:26 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
You suppose you're right..thanks
14th Mar 2021, 9:08 AM
El mhadji Mohamed abdelhak
El mhadji Mohamed abdelhak - avatar
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?
13th Mar 2021, 10:03 PM
Denise Roßberg
Denise Roßberg - avatar
0
First point("a",1,4) second Point ("b",3,1) it is suppose to give me 90 also
13th Mar 2021, 10:07 PM
El mhadji Mohamed abdelhak
El mhadji Mohamed abdelhak - avatar
0
The second should give me 90 but give me NaN why ?
13th Mar 2021, 10:14 PM
El mhadji Mohamed abdelhak
El mhadji Mohamed abdelhak - avatar