Respuesta :
Answer:
public static double drivingCost(int drivenMiles, double milesPerGallon,double dollarsPerGallon){
return (drivenMiles/milesPerGallon)*(dollarsPerGallon);
}
Find a complete java program that prompts the user to enter this values and the calls this Method in the explanation section.
Explanation:
import java.util.Scanner;
public class ANot {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please Enter the Driven Miles");
int drivenMiles = in.nextInt();
System.out.println("Please Enter the Your fuel consumption in miles/gallon");
double milesPerGallon = in.nextDouble();
System.out.println("Please Enter the cost of fuel in Dollars/gallon");
double dollarsPerGallon = in.nextDouble();
double dollarCost = drivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);
System.out.println("The Total Cost in Dollars is "+dollarCost);
}
public static double drivingCost(int drivenMiles, double milesPerGallon,double dollarsPerGallon){
return (drivenMiles/milesPerGallon)*(dollarsPerGallon);
}
}