• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java program method to calculate distance.  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys! I'm having a little trouble with this problem:

Write method distance, which calculates the distance between two points (x1, y1) and (x2, y2). All numbers and returned values should be of type double. Incorporate this method into an program that enable the user to enter the coordinates of the points, then calculate and display the distance by calling the method –distance.

I've tried numerous times to make it work and I'm on the right path, however I'm missing some things in the code to make my results look like this later on, which I've attached onto this post.

Thanks so much!

code.jpg
[Thumbnail for code.jpg]
Result
 
Bartender
Posts: 1840
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what have you got so far?

What does your program do right?
Where is it giving you a problem?

Please share your code, and UseCodeTags :-)
 
sw che
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:So what have you got so far?

What does your program do right?
Where is it giving you a problem?

Please share your code, and UseCodeTags :-)


Hello! So far, I've got this code. I'm working on the second file which I'm having issues with as well.



Thanks
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hay sw che ,
your code seems correct , the formula you are using is also correct , tell the exact problem you are facing

Satya
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Your problem is here, it involves a misplaced quote.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!