'How do I declare home and destination coordinate variables for my project?
My instructions state:At the top of the file, write your program prologue. Your code will be your main() function, as we have done in class. Your code should be written with good style, including comments for variables and constants, proper indentation, and appropriate use of whitespace. main() should begin with the constant declaration for the Earth's radius in miles (3963.1676). Use the keyword final to ensure your other code can't accidentally change the value of this variable. Declare and assign the variables to hold the home and destination coordinates. Convert the the home coordinates to variables of the appropriate types: You will need two double variables (one for latitude, one for longitude) and two char variables (one for the 'N' or 'S', and one for the 'E' or 'W', which appear after the numbers). For example, to convert the first argument, args[0], to a double variable latitude, use the statement: latitude = Double.parseDouble(args[0]); Similarly, to convert the second argument, args[1], to a char variable northSouth, use the statement, northSouth = args[1].charAt(0);
I am confused on what to actually do here. Do I have to write longitude and latitude and north/south and east/west for both the home and destination? How would I do that?
Solution 1:[1]
Declare and assign the variables to hold the home and destination coordinates
So yes, you do. The sentence starting "You will need ..." explains what you need for a single location.
As you are a beginner, just create variables for each of the attributes of each of the locations. You'll need to give them different names to distinguish home and destination.
When you have more experience you will create a class in situations like this, which can hold all four attributes of a location. Then you would just declare two references to your Location class, and create two instances of the class.
You can edit your question to explain exactly what you are unsure about.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tgdavies |
