Answer:
import java.util.Scanner;
public class LapToMiles {
public static void main(String[] args) {
System.out.println("Enter Number of Miles");
Scanner in = new Scanner(System.in);
double numMiles = in.nextDouble();
double numberOfLaps = milestoLaps(numMiles);
System.out.printf("%.2f",numberOfLaps);
}
public static double milestoLaps(double numMiles){
//One lap = 0.25 miles
double numberOfLaps = numMiles/0.25;
return numberOfLaps;
}
}
Explanation:
Create a Method milestoLaps that converts number of laps to number of miles
Within the main method call milestoLaps and pass your entered value for miles
format the output with printf()
You didn’t give any options?
Answer:
a. input={4,4}
b. input={3,6,6}
c. input={7,8,8,4}
d. input={5,7,7,4,4}
e input={4,6,6,7,9,9}
Explanation:
First understanding the method in the method we are iterating over array upto the second last element and in the loop we are checking that the current element is less than then next array element if it is less then we are assigning the value of next element to the current element.So the outputs are stated above according to the method execution.
Answer:
<u>note:</u>
<em><u>solution is attached in word form due to error in mathematical equation. furthermore i also attach Screenshot of solution in word due to different version of MS Office please find the attachment</u></em>