Results 1 to 2 of 2

Thread: JAVA how would I

  1. #1
    Join Date
    Feb 2009
    Posts
    96

    JAVA how would I

    can anyone tell me what an algorithm for the following situation would look like?

    i need to make a program in which the user enters a city name and x and y coordinates. depending on how many cities are entered, a recursion algorithm is used to determine the distance between the cities.

    like the following:

    if the user enters 3 cities and their coordinates:

    chicago x = 300 y = 500
    miami x = 100 y = 100
    toledo x = 10 y = 10

    then the program takes the x and y values to find the distance between the cities so the out put would look like:

    chicago to miami = 500 miles
    miami to toledo = 180 miles
    total miles = 680 miles



    thank you in advance

    Daren

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: JAVA how would I

    To measure the distance between the two cities, already there are classes and methods in java.awt that convert rectangular screen co-ordiantes to polar co-ordinates. To find out that you need to provide the appropriate class with (int x, int y, int delta-x, int delta-y) using city first(x,y) for the first two then city second(x,y) to the second pair of ints then call rectangular to polar and get magnitude on the result.

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Setting Of Java to The Point At Manual Java
    By winni in forum Software Development
    Replies: 4
    Last Post: 10-01-2011, 10:05 PM
  3. Java Programming using Adventnet SNMP Java API
    By ROCKING_Suhas in forum Software Development
    Replies: 5
    Last Post: 17-07-2010, 06:52 AM
  4. Link List Example in Java Sample program in Java
    By trickson in forum Software Development
    Replies: 2
    Last Post: 04-08-2009, 08:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,049,620.70637 seconds with 17 queries