Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
Java Programming Exercise: Reading and Visualising Elevation Data

Task 1

This exercise is about reading the elevation data into an array. Create a class called Earth in a file called Earth.java. This file should be in the package assignment. See the variables and methods the class must have in Figure 3. You may create additional methods and variables of your choice. All variables and methods should be private unless access is required.

Figure 3: Class Earth you should create for Exercise 1. IMPORTANT: This diagram only shows the variables and methods the class must have. It may be convenient to create additional variables and methods.

Add a method

public void readDataArray(String fileName){...}

to your Earth class. Replace the “. . . ” with your code. This method should store the data in a

private two-dimensional array of type double:

private double[][] arrayOfEarth

The first dimension should be the coordinate number, that means a line from the file. Each line should contain longitude, latitude and altitude (in this sequence). Thus the first dimension should have a size of approximately 2 million, the second of 3.

Add an additional four methods to your class:

public List<...> coordinatesAbove(double altitude){...}

public List<...> coordinatesBelow(double altitude){...}

public void percentageAbove(double altitude){...}

public void percentageBelow(double altitude){...}

Replace the “. . . ” with your code. Remember to also choose an appropriate type for the lists. The lists should contain all the coordinates below/above the specified altitude. The percentageAbove/percentageBelow methods should print the percentage of coordinates above or below the specified altitude to the command line with a precision of one value after the decimal point. All the methods in this part must use the data in arrayOf Earth.

Add code anywhere in your program that will prompt the user to enter an altitude (in meters or another unit of measurement if you prefer) on the command line and print the percentage of coordinates above this altitude. This prompt should query the user for new altitudes until the user enters “quit”. You should verify that the input is a valid altitude. An example of the output could look like this:

Please enter an altitude:

-2000

Proportion of coordinates above -2000.0 meters: 47.7%

Please enter an altitude:

30ddd

Invalid altitude. Please enter an altitude or "quit" to end program.

Please enter an altitude:

quit

Bye!

In this exercise you will read the same data into a Map data structure. Add the methods specified in Figure 4 to your Earth class. Note that the diagram only shows the new variables/methods.

Task 2

Write a method that reads the altitude data into a map data structure:

public void readDataMap(String fileName){...}

Replace “. . . ” with your code. The data should be stored in private variable of type map:

private Map<...> mapOfEarth;

Choose an appropriate implementation of Map and replace “. . . ” with an identifier for the elements in the map.

Write a method to generate a random map that will also be stored in map Of Earth. You can use this method instead of reading the data from the file should you not have the time to complete reading the file. You may generate completely random data (generating a random altitude for each coordinate). Attempting to generate realistic landmasses will not lead to higher marks. The method should receive a resolution that will define the number of coordinates. For example if the 

Figure 4: Methods for reading the elevation data into a Map data structure. Choose an appropriate type for the data in the map. An additional method should be provided to retrieve elevation data from the Map. IMPORTANT: This diagram shows only the methods added in Exercise 2.

resolution is 1 there will be 360 longitude * 180 latitude coordinates. If the resolution is 0.5 there will be 720 * 360, if the resolution is 2 there will 180 * 90 coordinates. The method should receive

a double and return void: public void generateMap(double resolution){...}

Replace “. . . ” with your own code.

Write a method that retrieves altitude data from the map data structure based on coordinates:

public double getAltitude(double longitude, double latitude){...}

Replace the “. . . ” with your code. The double that is returned should contain the altitude at the specified position.

Create a JFrame with a JComponent. You can use a design of your choice and any source code from the lecture notes, support classes and the lab solutions. 

In the JComponent visualise the altitude data at the corresponding coordinates from either the file or the randomly generated data. If you did not complete Exercise 2 you can generate random values between -5000 and +5000 in a grid of 360 by 180 pixels and draw those values onto the JComponent. The visualisation may be via grey scale.

There are two important aspects to the visualisation: the rate at which you sample the data in the file and the size of the visualisation you use to represent the altitude in your JComponent. If the size of the visualisation is too small gaps will appear and the colour of the background of your JComponent will show

Add some colour to your visualisation. To get credit for this part you must use one colour gradient for altitudes below 0 and a different colour gradient for altitudes above 0. The colour should show a variation that depends on the altitude, that means 50 m above zero should be distinguishable from 3000 m above zero. Have a look at (link) or Figure 1 for some inspiration on which colours you could use.

You may use as many different colour gradients as you wish but will receive full credit if you use at least two

Centre the map on 0 longitude. This should then be in the centre of your JComponent. If you are using a random array because you did not complete Exercise 2 centre on the first column of your array

Add a method that will shift the sea level of your rendering. Ideally you will modify the altitudes in the data structure that is the basis for your visualisation. Iterating over maps is a bit tricky but it is possible to do so with for-each loops by accessing the so-called entrySet. 

Add code to your program that reads the simulated sea level from args[]. You can set the parameter either through IntelliJ or using the command line. If you want to run your compiled IntelliJ code from the command line remember the binaries are stored in a folder called “out”. Set the sea level and visualise the altitude data accordingly (see Figure 5 and 6 for examples).

support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close