subject

I need help coding this ASAP Project 16A- Gas Mileage
package: mileage
Class: 2 files - Main. java, and Automobile. java

Create a class called Automobile in which you pass a gas mileage (miles per gallon)
parameter to the constructor which in turn passes it to the state variable, mpg. The
constructor should also set the state variable gallons (gas in the tank) to 0. A method called
fillUp adds gas to the tank. Another method, takeTrip, removes gas from the tank as the
result of driving a specified number of miles. Finally, the method reportFuel returns how
much gas is left in the car.

**Also throw in a way to calculate the cost of a trip to your interface.

Test your Automobile class by creating a Tester class as follows:

public class Tester
{
public static void main( String args[] )
{
//Create a new object called myBmw. Pass the constructor an
//argument of 24 miles per gallon
Automobile myBmw = new Automobile(24);

//Use the myBmw object to call the fillup method. Pass it an argument
//of 20 gallons.
myBmw. fillUp(20);

//Use the myBmw object to call the takeTrip method. Pass it an
//argument of 100 miles. Driving 100 miles of course uses fuel and we
//would now find less fuel in the tank.
myBmw. takeTrip(100);

//Use the myBmw object to call the reportFuel method. It returns a
//double value of the amount of gas left in the tank and this is assigned
// to the variable fuel_left
double fuel_left = myBmw. reportFuel( );
//Print the fuel_left variable

System. out. println(fuel_left); //prints gallons left, 15.833333333333332
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
Mastercard managers are motivated to increase (1) the number of individuals who have and use a mastercard credit card, (2) the number of banks and other clents who issue mastercards to customers and/or employees, and (3) the number of locations that accept mastercard payments. discuss how mastercard could use its data warehouse to it expand each of these customer bases.
Answers: 3
You know the right answer?
I need help coding this ASAP Project 16A- Gas Mileage
package: mileage
Class: 2 files -...
Questions
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
question
History, 27.06.2019 09:00
question
Mathematics, 27.06.2019 09:00
Questions on the website: 13722362