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, 22.06.2019 06:50
Match the personality traits with their description
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
Emma is using an artificial intelligence system, which contains information on botany, to identify a type of plant from an image. what type of ai is emma using?
Answers: 1
You know the right answer?
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon...
Questions
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
question
Mathematics, 18.03.2021 02:40
Questions on the website: 13722363