Answer:
Step-by-step explanation:
The following is written in Java. The first DrivingCost function requested in the question cannot be made and will not work because the cost cannot be calculated without the miles driven being input as a seperate variable. The second DrivingCost function with all three variables was created and tested using the example in the question. The test and output can be seen in the attached image below highlighted in red.
public static float DrivingCost(float drivenMiles, float milesPerGallon, float dollarsPerGallon) {
float gallonsUsed = drivenMiles / milesPerGallon;
float cost = dollarsPerGallon * gallonsUsed;
return cost;
}