One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a number of miles as an argument and returns the number of laps. Complete the program to output the number of laps. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value)) Ex: If the input is: 1.5 the output is: 6.00 Ex: If the input is: 2.2 the output is: 8.80 Your program must define and call the following function: def miles_to_laps(user_miles)

Respuesta :

Answer:

Java.

Explanation:

import java.util.Scanner;

///////////////////////////////////////////////////////////

public class MyClass {

   static void miles_to_laps(float miles) {

       double laps = miles/0.25;

       System.out.printf("Number of laps: %s", String.format("%.2f", laps));

   }

///////////////////////////////////////////////////////////

   public static void main(String args[]) {

       System.out.print("Enter miles: ");

       Scanner input = new Scanner(System.in);

       float miles = input.nextFloat();

       if (miles < 0) {

           System.out.println("Invalid input");

       }

       else

           miles_to_laps(miles);

   }

}

I have used the Scanner library for user input.

Answer:

def miles_to_laps(user_miles):

return user_miles/0.25

if __name__ == '__main__':

miles = float(input(""))

lap = miles_to_laps(miles)

print("%.2f"%lap)

Explanation:

because it works.

ACCESS MORE