Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ignore the “main” method for now. After the “main” method, create a new public s

ID: 3883294 • Letter: I

Question

Ignore the “main” method for now. After the “main” method, create a new public static double method called “calcSeconds” that accepts a double parameter representing a number of miles.

• In that method, divide the number of miles by the speed of light (use 186,000 miles per second) and store the result. Return that result from your method and save the value.

• After the “calcSeconds” method, create a new public static String method called “calcTime” that accepts an int parameter representing a number of seconds (Example: 8,000).

• Calculate and store the int number of hours in the provided number of seconds. (There are 3,600 seconds in an hour). Example: 8,000 / 3,600 = 2 HOURS

• Next, subtract the number of seconds in the previously calculated number of hours from the original seconds value passed in. Example: int newSeconds = 8,000 – (2 * 3,600) = 800

. • Calculate and store the int number of minutes in the calculated number of seconds. (There are 60 seconds in a minute). Example: 800 / 60 = 13 MINUTES

• Next, subtract the number of seconds in the previously calculated number of minutes from the new number of seconds you calculated earler. Example: newSeconds = 800– (13 * 60) = 20.

• The value you just calculated of the number of SECONDS. • Create a String that contains the hours, minutes, and seconds values in the following format:

o H:M:S (For example, “2:13:20”)

• Return that String from your method

• Back in the “main” method, create a Scanner object to read user keyboard input.

• Prompt the user to provide a number of miles. Read and store the user input.

• Call your calcSeconds method (passing it the distance value the user entered as the parameter) and be sure to save the returned double value. This is the number of seconds for light to travel that distance. • Print the decimal seconds value: Seconds: 1234.56

• Convert that decimal value to a whole number: int newSeconds = (int) doubleSeconds;

• Then call your calcTime method (passing it the int number of seconds you calculated in the previous step as the parameter) and be sure to save the returned String value. This is the String holding the H:M:S value representing the time light takes to travel to the user-specified distance).

• Print that resulting String in the following format: H:M:S = 1:50:37

• Done! Test with the following distances:

o The Sun to Earth: 92,900,000 miles 499.4623655913978 H:M:S = 0:8:19

The Sun to Jupiter: 484,000,000 miles 2602.1505376344085 H:M:S = 0:43:22

o The Sun to Neptune: 2,771,000,000 miles 14897.849462365592 H:M:S = 4:8:17

o The Sun to Pluto: 3,670,000,000 miles 19731.182795698925 H:M:S = 5:28:51

Explanation / Answer

Method calcSeconds

public static double calcSeconds(double miles){
double seconds = miles/186000;
return seconds;
}
calcTime
public static calcTime(int seconds){
int hours = seconds/3600;
seconds -= hours*3600;
int minutes = seconds/60;
seconds -= minutes*60;
String hms = hours+":"+minutes+":"+seconds;
return hms;
}

PLEASE RATE !!

THanks !!