# i have all this program but from nyc units away i can do it help plz

 mostafa refaii · August 1, 2014 Create a new class called "City" that can be used to keep track of location information for a given city. Your class should include the following – be sure to comment your class appropriately: A. String name B. double lon (for longitude) C. double lat (for latitude) D. A constructor that accepts a name, lon and lat value and stores them in the instance variables for the object E. A method that reports the current position of a city. Here’s a method header to get you started: public void report() F. A method that computes the distance from the lon and lat of one city to the lon and lat of another city. Use the standard distance formula to compute this value (let’s pretend that the cities lie on a flat plane and not on a sphere!) G. Develop a main program to use the City class, in which do the following: 1. Prompt the user to enter in a number of cities (i.e. How many cities do you want to create?) 2. Next, ask the user to enter in the name, lon and lat for each city. Note that you will probably need to use two scanners since you are asking for both String and double data. Create a new City object and store it in an array that is designed to hold objects of type City (i.e. City[] myCities) 3. Iterate through your array of Cities and ask each city to report its position. 4. Iterate through your array of Cities and compute the distance from each city to each other city. Ensure that you do not calculate the distance from a given city back to itself (i.e. no need to compute distance between NYC and NYC – the result will be zero) — Here’s a sample running of your program. How many cities? 3 City # 1 Enter name: NYC Enter longitude: 50 Enter latitude: 75 City # 2 Enter name: Chicago Enter longitude: 25 Page 4 of 5 Enter latitude: 10 City # 3 Enter name: LA Enter longitude: 0 Enter latitude: 50 -------- City: NYC is at: 50.0, 75.0 City: Chicago is at: 25.0, 10.0 City: LA is at: 0.0, 50.0 NYC is 69.6419413859206 units away from Chicago NYC is 55.90169943749474 units away from LA Chicago is 69.6419413859206 units away from NYC Chicago is 47.16990566028302 units away from LA LA is 55.90169943749474 units away from NYC LA is 47.16990566028302 units away from Chicago

## Replies

 mostafa refaii · August 1, 2014 I have program with this how to make NYC constant to make the distance with Chicago and la then make Chicago like nyc I have made the equation and everything is right in the header but I want to know how to make that in mainNYC is 69.6419413859206 units away from Chicago NYC is 55.90169943749474 units away from LA Chicago is 69.6419413859206 units away from NYC Chicago is 47.16990566028302 units away from LA LA is 55.90169943749474 units away from NYC LA is 47.16990566028302 units away from Chicago
• 1

## C++

130,010 followers