subject

Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975. Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method three times. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System. out. printf("%.2f", yourValue); the output ends with a newline. ex: if the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20your program must define and call a method:public static double drivingcost(double drivenmiles, double milespergallon, double dollarspergallon)my code that keeps giving me errors no matter how i input it:import java. util. scanner;public class labprogram {/* define your method here */public static double drivingcost(double drivenmiles, double milespergallon, double dollarspergallon); {return drivenmiles * (1.0 / milespergallon) * dollarspergallon;}public static void main(string[] args); {/* type your code here. */public static void main(string[] args); {scanner scnr = new scanner(system. in);double milespergallon;double dollarspergallon;// set 'milespergallon' equal to 'scnr. nextdouble()'// set 'dollarspergallon' equal to 'scnr. nextdouble()'system. out. printf("%.2f ", drivingcost(10.0, milespergallon, dollarspergallon));}}i usually do not post things online asking for , but at this point i am completely stumped.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 00:10
Read each statement below. if the statement describes a peer-to-peer network, put a p next to it. if the statement describes a server-based network, put an s next to it. p - peer-to-peer s - server-based
Answers: 1
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
(, urgent need): how do i change my username
Answers: 1
question
Computers and Technology, 25.06.2019 08:00
The heart of a computer.basic input/output systemselectmain memoryserial portcentral processing unit (cpu)
Answers: 3
You know the right answer?
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon...
Questions
question
Mathematics, 23.07.2020 01:01
question
Mathematics, 23.07.2020 01:01
question
Social Studies, 23.07.2020 01:01