Question: Write a java that: - Has the method modifiers public static Has the name convertDistance Receives two parameters: the first is of type double ,
Write a java that:
- Has the method modifiers public static Has the name convertDistance Receives two parameters: the first is of type double , which you should call distance , and the second is of type String, which you should call distanceMeasurement The return of the method should be a double The body of the method should have an if , else if , else statement. Depending on the value of the argument distanceMeasurement , the method should convert the value saved in the variable distance from Miles to Kilometers if distanceMeasurement is m, M or Miles , or convert distance from Kilometers to Miles if distanceMeasurement is is k, K or Kilometers. If distanceMeasurement is is not a one of the above possibilities, the method should print an error message.

The skeleton of the if statement is the following: if ( /* distance Measurement letter 1, M of Miles */ ) { // code lhal. converts from miles lo kilomelers } else if (/* distance Measurement letter k, K of Kilometers */) { // code that converts from kilometers to miles } else { // code lhal. Oul.puls a message indicaling lhal. an incorrecl. // optiori was selected . Use the following conversion formula, to convert the value that is input to the method: Kilometers = Miles * 1.60934 Miles = Kilometers * 0.621371
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
