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 01:00
How can a broadcast station be received through cable and satellite systems?
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
You know the right answer?
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon...
Questions
Questions on the website: 13722363