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, 23.06.2019 00:30
Quic which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Which option completes the explanation for conflict of interest in an organization
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
Which two technologies support the building of single-page applications?
Answers: 2
question
Computers and Technology, 24.06.2019 10:20
Identify the publisher in this citation: carter,alan.a guide to entrepreneurship.new york: river’2008.print.
Answers: 3
You know the right answer?
I need help coding this ASAP Project 16A- Gas Mileage
package: mileage
Class: 2 files -...
Questions
question
Physics, 26.08.2021 05:50
question
Mathematics, 26.08.2021 05:50
question
Chemistry, 26.08.2021 05:50
question
Social Studies, 26.08.2021 05:50
Questions on the website: 13722361