Respuesta :
Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of miles: ");
float miles = input.nextFloat();
System.out.println("The number of laps: " + MilesToLaps(miles));
}
public static float MilesToLaps(float userMiles){
float userLaps = userMiles / 0.25F;
return userLaps;
}
}
Explanation:
Create function called float MilesToLaps that takes one parameter, userMiles
Calculate the user laps, dividing userMiles by 0.25 (Since all the variables are float in the question it is better to add "F" after 0.25 to avoid getting loosy conversion error) and return the user laps.
Inside the main, ask the user for the miles. Call the the function with the miles and print the result.
Answer:
def miles_to_laps(miles):
return miles / 0.25
miles = 5.2
num_of_lap = miles_to_laps(miles)
print("Number of laps for %0.2f miles is %0.2f lap(s)" % (miles, num_of_lap))
Explanation: