Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:30, lilpeepxliltracy
This technology is used to produce high-quality documents that look good on the computer screen and in print.
Answers: 1
image
Computers and Technology, 22.06.2019 15:30, tfornwalt4390
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
image
Computers and Technology, 22.06.2019 17:40, lazerlemon500
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i. e., still have an asterisk in it).
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, yayamcneal05
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
Do you know the correct answer?
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon...

Questions in other subjects:

Konu
Mathematics, 30.05.2020 06:58
Konu
History, 30.05.2020 06:58
Konu
Chemistry, 30.05.2020 06:58