Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider only starting to read the input again. If it is what you need, the following would be suitable:</p> <p>Put the method getData() in the Distance class. The class Distance must have a nonparametric constructor.</p> <p>Distance.java</p> <pre><code>private double latitude; private double longitude; private double elevation; private double latitude2; private double longitude2; private double elevation2; public Distance() {} public boolean getData(){ Console.WriteLine("Please enter the two points that you wish to know the distance between:"); string point = Console.ReadLine(); string[] pointInput = point.Split(' '); int pointNumber = Convert.ToInt16(pointInput[0]); int pointNumber2 = Convert.ToInt16(pointInput[1]); try{ latitude = (Convert.ToDouble(items[pointNumber * 3])); // longtitude = (Convert.ToDouble(items[(pointNumber * 3) + 1])); // elevation = (Convert.ToDouble(items[(pointNumber * 3) + 2])); // latitude2 = (Convert.ToDouble(items[pointNumber2 * 3])); // longtitude2 = (Convert.ToDouble(items[(pointNumber2 * 3) + 1])); // elevation2 = (Convert.ToDouble(items[(pointNumber2 * 3) + 2])); // I assume the exception goes from these 6 lines return true; } catch (IndexOutOfRangeException) { return false; } } </code></pre> <p>Main.java:</p> <pre><code>Distance curDistance = new Distance(); while(!curDistance.getData()) Console.WriteLine("You have selected a point number outside the range of the data entered, please select two new pointnumbers"); Console.WriteLine("The distance in km's to two decimal places is:"); Console.WriteLine(String.Format("{0:0.00}", curDistance.toDistance()) + "km"); </code></pre> <p>The while loop makes the program ask for the input as long as it's incorrect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload