Contact us - +12567847275

“);
}
}

Coordinates.java

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

getTopNcountriesWithMostAirports

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.

getClosestAirport

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.

countAirportsByAltitude

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

averageNumAirportsPerCountry

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

percentAirportsWithCityName

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.

—————————————————————

Airport.java
/**
* 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 https://openflights.org/data.html 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;
this.name = name;
this.city = city;
this.country = 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;
}
@Override
public String toString() {
return airportID + “,” + name + “,” + city + “,” + country + “,” +
iataCode + “,” + icaoCode + “,” +
coordinates + “,” + altitude;
}
@Override
public boolean equals(Object otherObject) {
if (otherObject instanceof Airport) {
Airport other = (Airport) otherObject;
return airportID == other.airportID &&
name.equals(other.name) &&
city.equals(other.city) &&
country.equals(other.country) &&
iataCode.equals(other.iataCode) &&
icaoCode.equals(other.icaoCode) &&
coordinates.equals(other.coordinates) &&
altitude == other.altitude;
}
return false;
}
/**
* compares lexicographically by airport name
*/
@Override
public int compareTo(Airport other) {
if (name.compareTo(other.name) < 0)
return -1;
if (name.compareTo(other.name) > 0)
return 1;
return 0;
}

}

————————————————–

AirportsReader.java
import java.io.File;
import java.io.FileNotFoundException;
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
airports
*
* @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);
scanner.useDelimiter(“,”);
int airportID = scanner.nextInt();
String name = removeQuotes(scanner.next());
String city = removeQuotes(scanner.next());
String country = removeQuotes(scanner.next());
String iataCode = removeQuotes(scanner.next());
String icaoCode = removeQuotes(scanner.next());
double latitude = scanner.nextDouble();
double longitude = scanner.nextDouble();
Coordinates coordinates = new Coordinates(latitude,
longitude);
double altitude = scanner.nextDouble();
scanner.close();
airports.add(new Airport(airportID, name, city, country,
iataCode, icaoCode, coordinates,
altitude));
}
} catch (FileNotFoundException e) {
System.out.println(“File: ” + filename + ” not found”);
}
return airports;
}

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

Solution:

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.