Contact us - +12567847275


* Represents a set of latitude/longitude coordinates
public class Coordinates {
public final double latitude;
public final double longitude;
public Coordinates(double lat

Programming Language: java

any copy answer (ofc, there is a wrong answer in Chegg. If you copy and paste, I will just report it as abuse/spam)

The Question description.


Given a Stream of airports and an int n, return a list of the names of the top n countries with the most airports, sorted in descending order by number of airports. If there are < an n countries represented in the stream, return them all, sorted in descending order by number of airports.


Given a Stream of airports and an airport ID, return the airport closest to the airport with that ID. Use the Coordinates.distance method to calculate distance between airports, and the Stream.min method to find the airport with the minimum distance away. If the airport with the given ID is not found, or the stream is empty, return an empty Optional.


Given a Stream of airports, return a Given a Map that maps altitudes to the number of airports at that altitude, but only include in the map altitudes that have at least 2 airports at that altitude. If the stream is empty, return an empty map.

return a list of movies with exactly n words in the title (use String.split(“\s+”) to split the title string into words).


Given a Stream of airports, return the average number of airports in each country, of 0 if the stream is empty.


Given a Stream of airports, return the percentage of airport names that contain the name of the city they are in (case-insensitive). If a city name is blank, consider the airport name to NOT contain it. If the stream is empty, return 0.

* Represents an Airport
public class Airport implements Comparable {
private int airportID;
private String name;
private String city;
private String country;
private String iataCode;
private String icaoCode;
private Coordinates coordinates;
private double altitude;
* See for what each parameter means
* @param airportID
* @param name
* @param city
* @param country
* @param iataCode
* @param icaoCode
* @param coordinates
* @param altitude
public Airport(int airportID, String name, String city, String country,
String iataCode, String icaoCode,
Coordinates coordinates, double altitude) {
this.airportID = airportID; = name; = city; = country;
this.iataCode = iataCode;
this.icaoCode = icaoCode;
this.coordinates = coordinates;
this.altitude = altitude;
public int getAirportID() {
return airportID;
public String getName() {
return name;
public String getCity() {
return city;
public String getCountry() {
return country;

public String getIATAcode() {
return iataCode;
public String getICAOcode() {
return icaoCode;
public Coordinates getCoordinates() {
return coordinates;
public double getAltitude() {
return altitude;
public String toString() {
return airportID + “,” + name + “,” + city + “,” + country + “,” +
iataCode + “,” + icaoCode + “,” +
coordinates + “,” + altitude;
public boolean equals(Object otherObject) {
if (otherObject instanceof Airport) {
Airport other = (Airport) otherObject;
return airportID == other.airportID &&
name.equals( &&
city.equals( &&
country.equals( &&
iataCode.equals(other.iataCode) &&
icaoCode.equals(other.icaoCode) &&
coordinates.equals(other.coordinates) &&
altitude == other.altitude;
return false;
* compares lexicographically by airport name
public int compareTo(Airport other) {
if (name.compareTo( < 0)
return -1;
if (name.compareTo( > 0)
return 1;
return 0;


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
* A utility class for reading a CSV-type formatted file of airports
public class AirportsReader {
* Reads a CSV-type formatted file of airport data, and returns a list of
* @param filename the CSV file with the airport data to read
* @return a list of airports from the file
public static List readAirports(String filename) {
List airports = new ArrayList<>();
try (Scanner in = new Scanner(new File(filename))) {
while (in.hasNextLine()) {
String line = in.nextLine();
* The format of each line is idnumber,”Airport Name”,”City
Name”, … There are
* no commas in the the airport or city name fields.
Scanner scanner = new Scanner(line);
int airportID = scanner.nextInt();
String name = removeQuotes(;
String city = removeQuotes(;
String country = removeQuotes(;
String iataCode = removeQuotes(;
String icaoCode = removeQuotes(;
double latitude = scanner.nextDouble();
double longitude = scanner.nextDouble();
Coordinates coordinates = new Coordinates(latitude,
double altitude = scanner.nextDouble();
airports.add(new Airport(airportID, name, city, country,
iataCode, icaoCode, coordinates,
} catch (FileNotFoundException e) {
System.out.println(“File: ” + filename + ” not found”);
return airports;

private static String removeQuotes(String str) {
return str.replaceAll(“””


15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.