subject

I've been having a hard time getting the system to accept any code i enter.
here is my assignment:
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.20
your 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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, mazolethrin9632
Which of these is most responsible for differences between the twentieth century to the twenty-first century?
Answers: 2
image
Computers and Technology, 23.06.2019 10:00, uwunuzzles
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, Gearyjames8
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, larry5007
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
You know the right answer?
I've been having a hard time getting the system to accept any code i enter.
here is my assignm...

Questions in other subjects:

Konu
Business, 20.07.2019 07:30