0

Complete the SADITM for the the following problem .  Write a distance calculator which will read the coordinates for two points.

Hello i am a beginner in Java and i need help Understanding SADITM's. For example Here is a formula given distance given the square root of (x2-x1)^2 + (y2-y1)^2

23rd Sep 2021, 3:22 PM
Sandra2222?
11 Respostas
+ 3
Martin Taylor Oh, that's amazing! I can say that I'm just beginner in Java so I don't know more information about it. But, I'm collecting some experience with writing some basic codes myself. Also, thanks a lot for this information. I've learnt new thing! :)
23rd Sep 2021, 5:52 PM
mesarthim
mesarthim - avatar
+ 2
Yes. actually java is self-sufficient whenever i read something about some apis or computer-related situations, I expect java to solve this issue by its API .for example when i read about base64 encoding , first one i searched for it in java API and i found Base64 class very soon.
23rd Sep 2021, 7:09 PM
Mehran
Mehran - avatar
+ 1
This is the distance between the points are coordinated where x-y planes. Just some of mathematical calculations. For example: Given coordinates are Point 1 = (-3,0) : x1 = -3, y1 = 0, Point 2 = (-1, 3) : x2 = -1, y2 = 3 Find the distance this two points. Distance^2 = (-1-3)^2 + (3-0)^2 A distance can't be negative so when we solve the equation we get, Distance = 5 As Java code: int x1 = nextInt(); int y1 = nextInt(); int x2 = nextInt(); int y2 = nextInt(); int distance = ((x2)-(x1))*((x2)-(x1)) + ((y2)-(y1))*((y2)-(y1)); distance = Math.sqrt(distance); System.out.println(distance); Try this, you'll see. I hope, it helps. Happy coding!
23rd Sep 2021, 4:12 PM
mesarthim
mesarthim - avatar
+ 1
Thanks alot
23rd Sep 2021, 4:19 PM
Sandra2222?
+ 1
Sandra2222? You're welcome and you can check my code! Good luck! https://code.sololearn.com/cKGwo322HqCL/?ref=app
23rd Sep 2021, 4:21 PM
mesarthim
mesarthim - avatar
+ 1
Waohhhh thanks guys
23rd Sep 2021, 8:48 PM
Sandra2222?
+ 1
I have really learnt alot in just few minutes just being on here
23rd Sep 2021, 8:50 PM
Sandra2222?
0
Waohhh this i believe will work when writing the code
23rd Sep 2021, 4:18 PM
Sandra2222?