public class Time { public static void Main(String[] args) { int minutes = Integer.parseInt(args[0]); // convert String to int System.out.pritln(minutes + " minutes") } }If you copied it exactly, you will find when compiling that there are errors. The output of the compilation tells you where "compile time" errors are (or at least gives you strong hints as to where). However the compile does not tell you about run time errors.Fix this program.
VSC also tells you about compile time errors. In general, they are underlined in red squiggles. When you hover over a red underline, you will see pretty much the same error message that you would get from the compiler.
geoffreytowell@Geoff2020Mac HW2 % java Time 473 7 hours and 53 minutes geoffreytowell@Geoff2020Mac HW2 % java Time 53 0 hours and 53 minutes geoffreytowell@Geoff2020Mac HW2 % java Time 152 2 hours and 32 minutes
You may assume that the input to the program is a positive integer, i.e. a whole number greater than 0. You do not have to worry about the case in which the input is missing, a negative number, a fraction, something that is not a number, etc.
java Arrival 11 10 15 60 Arrival Time is 11:25 java Arrival 15 50 125 50 Arrival Time is 18:20 java Arrival 22 15 110 60 Arrival Time is 0:5Note that in the last example, the time would ordinarily be displayed as “00:05” but it is okay to omit the leading “0” for the purposes of this assignment. After reading the four runtime arguments, your program should be implemented according to these steps:
d = earthRadius * arccos(sin(lt1) * sin(lt2) + cos(lt1) * cos(lt2) * cos(lg1 - lg2))where you can use the earth's radius = 3986 miles. Since the inputs are meant to be doubles, you will need to use the Double.parseDouble function to convert the program inputs from Strings to doubles. To calculate the distance, you will need to use the Math.sin, Math.cos, and Math.acos functions to perform the sine, cosine, and arccosine trigonometric functions, respectively. For instance:
double s = Math.sin(angle);returns the sine of angle and stores it in the variable s. However, the latitude and longitude of the two points are in degrees, whereas Java's trigonometric functions use radians. Use Math.toRadians(a) to convert the angle a from degrees to radians before using the sine and cosine functions. The following example shows the output for the distance between Philadelphia (39.9526 N and 75.1652 W) and Honolulu (21.3069 N and 157.8583 W):
java Distance 39.9526 75.1652 21.3069 157.8583 4945.290632589314 miles //This next example shows the distance between Paris (48.87 N and -2.33 W) and San Francisco (37.8 N and 122.4 W): java Distance 48.87 -2.33 37.8 122.4 5598.250822014901 milesYou may assume that the four inputs to the program exist and are all valid latitudes (floating point numbers between -90.0 and 90.0) and longitudes (floating-point numbers between -180.0 and 180.0).
You should have 3 files in your HW2 directory: Time.java, Arrival.java, Distance.java, and Readme. (You might also have .class files.)
cd cd CS113 mkdir HW2Once you have made the HW2 directory in Unix, open a terminal on you own computer and in that terminal use "cd" to navigate to the directory containing your work for this assignment. Assuming you use the same directory structure on your own computer and in the lab, this process can be accomplished with the following commands
cd cd CS113 cd HW2Then use the scp command to copy files from your computer to the lab
scp Time.java UNIX_NAME@goldengate.cs.brynmawr.edu:CS113/HW2/Time.java scp Arrival.java UNIX_NAME@goldengate.cs.brynmawr.edu:CS113/HW2/Arrival.java scp Distance.java UNIX_NAME@goldengate.cs.brynmawr.edu:CS113/HW2/Distance.java scp Readme UNIX_NAME@goldengate.cs.brynmawr.edu:CS113/HW2/ReadmeIn each of the above commands, when you read "UNIX_NAME" put in your UNIX user name. Also, with each scp command you will need to enter your UNIX password. scp is much like cp except that scp allows copying between machines. "UNIX_NAME@goldengate.cs.brynmawr.edu:" in the scp command given the name of the machine to copy to -- in this case goldengate.cvs.brynmawr.edu -- and the account name to put it in.
cd cd CS113 /home/gtowell/bin/submit -c 113 -d HW2 -p 2In response to the submit command you should see a series of messages ending with:
Submitting archive... Submission complete! Submission timestamp is 2023-08-08-15-30-28-EDT.