Question 2.23
unknown
java
3 years ago
612 B
7
Indexable
import java.util.Scanner;
public class QuestionTwoPointTwentyThree
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the driving distance:");
double distance = scanner.nextDouble();
System.out.println("Enter the miles per gallon:");
double mpg = scanner.nextDouble();
System.out.println("Enter the price per gallon:");
double price = scanner.nextDouble();
double cost = ((distance/mpg)*price);
System.out.printf("The cost of driving is $ %.2f", cost);
}
}Editor is loading...