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

  Java script program for song

Construct a JavaScript program that declares and prints an array that includes at least twenty of your favorite songs.

  Mean and standard deviation using using eclipse

Java programming to calculate Mean and standard deviation using Using Eclipse.

  Programming exercises

Programming Exercises 1. Write an application named BadSubscriptCaught in which you declare an array of 10 first names. Write a try block in which you prompt the user for an integer and display the name in the requested position.

  supply a student tester class that tests all methods

Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods getName( ), addQuiz(int score), getTotalScore( ), and getAverageScore ( ).

  Write a class named test scores

Write a class named TestScores.The class constructor should accept an array of test scores as an argument.The class should have a method that returns the average of the test scores.

  Construct java program named collegelist

Construct a set of classes for a college to use in many student service and personnel applications. Classes you require to design include following:

  Write java program to receive input and displayed interest

Write a Java program that receive some input and displayed the interest. Format the number into 2 decimal places. Using loop is an advantage.

  Produce a design document

You will design and deliver a website foes fictional client part-1 Website Design Document and produce a design document

  One search function

One search function will use a sentinel to mark the end of the array. The other search function will use an array length (maximum legal index into the array) to determine when to exit the search loop. Both functions must return true when the searc..

  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.

  Implementation of memory management

Implementation of memory management

  Elements from a html document

Function test Count List Elements should simply retrieve an array of all list elements on the page and assert that their total count is 3.

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