Answer:
import java.util.Scanner;
public class Miles {
public static void main(String[] args) {
//initialization
double Number_Miles;
//print the message
System.out.print("Enter the number of miles: ");
Scanner scn1 = new Scanner(System.in);
Number_Miles = scn1.nextDouble(); //read the input from user
//calculate the laps
double yourValue = Number_Miles/0.25;
//display the output on the screen
System.out.printf("%.2f", yourValue);
}
}
Explanation:
First import the library Scanner than create the class and define the main function. In the main function, declare the variables.
print the message on the screen and then store the value enter by the user into the variable.
Scanner is a class that is used for reading the output. So, we make the object of the class Scanner and then object call the function nextDouble() which reads the input and store in the variable.
After that, calculate the number of laps by dividing the number of miles with the given one lap running track value (0.25 miles).
the output is stored in the variable.
After that, print the value on the screen with 2 digits after the decimal point.
we can use "%.2f" in the printing function in java.
like System.out.printf("%.2f", output);