A method with the signature public static void

Assignment Help JAVA Programming
Reference no: EM13165024

Write a program that will create three city objects (described below) containing name,longitude, and latitude information. The information for the cities will be displayed along with the distance betweenthe cities.The requirements are s follows:

  • Define a class named City which will contain the following:

o A String name field

o A double longitude field

o A double latitude field

o A constructor that takes the name,longitude,and latitude as parameters.

o Setter and getter methods for all fields.

o A method with the signature public double distanceFrom(City otherCity) that will calculate and return the distance

between one city and the other city using the standard distance formula sqrt((x1-x2)2 + (y1-y2)2).

o A method with the signature public void displayDetails() that will write the details of the city to the console.

Refer to the example output below.

  • Define a class named LastnameHw4 which will contain the following:

o A main method

o A City[] cities field

o A method with the signature public static void printDistances(City[] cities) that will iterate through the cities andprint the distance between the city and all other cities using the distanceFrom(...) method.Be sure not to print thedistance from a city to itself as the result would always be 0.

Refer to the example output below.

o A method with the signature public static void printDetails(City[] cities) that will iterate through the cities and printthe details of the city using the displayDetails(...) method.

  • The main method will do the following:

o Create three cities and store them in the cities array field.

o Call the printDetails(..) method to display the details of the cities.

o Call the printDistances(...) method to display the distances between the cities.

  Be sure to use proper coding conventions including indentation, constants,and

Computer Science

Reference no: EM13165024

Questions Cloud

What are mole fraction of methanol in this solution : A 2.9 m solution of methanol (CH3OH) in water has a density of 0.984 g/ml. What are the a) mass percent, b) molarity, and c) mole fraction of methanol in this solution?
Which element is most likely to be element x : An unknown element, X, reacts with chlorine to form a compound with the formula XCl2. Which element is most likely to be element X?
Violations of criminal law : Violations of criminal law can be of different types and can vary in severity.  Describe five categories of violations.
What is the activation energy for a reaction : What is the activation energy for a reaction if its rate constant is found to triple when the temperature is raised from 300 k to 310 k.
A method with the signature public static void : A method with the signature public static void printDetails(City[] cities) that will iterate through the cities and printthe details of the city using the displayDetails(...) method.
Describe the molecular geometry of formic acid : describe the molecular geometry of formic acid in terms of hybrid orbitals,bond angles and sigma and pi bond, and how many lone pairs are in the molecule.
State the number of hydrogens on a particular carbon : From a purely statistical standpoint -considering only the number of hydrogens on a particular carbon that could be lost from the intermediate carbocation
Why could you not visually detect these colors : when most Fe+3 salts are dissolved in dilute nitric acid, the solution is often yellow to orange in color. Why could you not visually detect these colors in the Fe(NO3)3 stock solution?
How many grams of oxygen reacted with the phosphorus : How many grams of oxygen reacted with the phosphorus?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd