I am working on a project where the user enters a planet name and the program uses an array to verify that it is a real planet and a seperate array to hold each planets diameters. The diameter array is set up so its entries are in the same order are the entries in the planet name array. I will put them both below for the sake of reference:
String[] verifyPlanet = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"};
double[] getDiameter = {3031.9, 7520.8, 7917.5, 4214.3, 86881, 72367, 31518, 30599};
I am looking for a way to find what entry number a planet is in the first array, and use it to find the diameter in the second. for example, the user would enter "Mercury", it would be confirmed to be a planet name, then I would somehow have a command that outputs 0, so i could simply enter getDiameter[Arrays.COMMANDEXAMPLE(verifyPlanet)]
to output the corresponding diameter. just for the sake of avoiding ambiguity, I am looking for the code that would replace COMMANDEXAMPLE so that command outputs 0. Thanks in advance!