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 program in java for total amount of customer-s order

Write down program in Java which would ask for clerk to enter total amount of customer's order. Program will then compute seven percent (7%) sales tax.

  Accepts a binary number from the user

Write a Java test program that accepts a binary number from the user. You should store the binary number in a String. Your program should then use afor loop to sequence through every character in the String, counting the number of ones, zeros, and..

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

  Write java program to store employee id number

Use employee data file called employees.txt should comprise at least 5 employee records. Each record stores employee ID number (six digits) last name, first name, middle inital,gender(m or f).

  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.

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  Regular expression that selects lines

Write a regular expression that selects lines containing the html BR tag. The rules for this tag are that, like all html tags, it starts with . In between are the letters b and r in that order

  Program to translates a number into the closest letter grade

Write a program that translates a number into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B-. Break ties in favor of the better grade

  Describe principles of data abstraction and inheritance

Study the principles of data abstraction, inheritance and dynamic binding. Use Library to get started on finding resources.You must take the terms and describe it.

  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..

  Build the gui layout of the game

Build the Build the GUI layout of the game in java.

  Write a program that asks the user to enter three names

Write a program that asks the user to enter three names

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