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

  Write method called median that accepts an array of integer

Write a method called median that accepts an array of integers as its parameter and returns the median of the numbers in the array.

  Write down java program for furniture company

Write down a Java program for the furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate price of table manufactured with chosen wood.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Ask the user to enter a positive non-zero integer value.

Write a program which aske the user to Enter a positve non-zero integer value. if the value enterd zero or negative print as error message and end the program; otherwise, use the integer to call a method displayPattern(n) which must display the follo..

  Write java applet for costco gas station

Write a java applet for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use: grade 87, 89, or 91.

  Java-s ability to derive new fonts from existing ones

Find out where on your system these font libraries are located. When you do, please specify the operating system and the location (folder/directory) where you found them. Discuss Java's ability to derive new fonts from existing ones.

  The data file being used contains records

The data file being used contains records with an employee's name, the number of hours they worked, and their hourly pay rate. Write a program to read the records of information and output (to the Output window or a dialog box) the employee's name..

  Afterwards a way for the user to input

And so on and so forth then afterwards a way for the user to input that they finished a particular task on the list. After the user has input that they have finished a particular task the program should be print "Good Job!" or "Keep it up!"

  Write java program to evaluate postfix expressions

Write a java program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes.

  Give at least one constructor without any parameter

We learned as popular Set implementation. Write own TreeSet class that implements following interface: You are to give at least one constructor without any parameter.

  Data structures and algorithms

Code analysis and programming.

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