subject

Implement a class Car with the following properties:(IN JAVA) A car has a certain fuel efficiency (measured in miles/gallon) and a certain amount of fuel in the gas tank.
The efficiency is specified in the constructor; in addition, in the constructor:
The initial fuel level is 0.
The initial miles driven is 0.
Supply a method drive that simulates driving the car for a certain distance, reducing the fuel level in the gas tank.
Supply a method getGasLevel to return the current fuel level.
Supply a method getMileage to return the total miles driven.
Supply a method addGas to tank up.
Implement a (second) main tester class with the following source code:
Car myHybrid = new Car(50); // 50 miles per gallon
myHybrid. addGas(20); // Tank 20 gallons
myHybrid. drive(100); // Drive 100 miles
System. out. println(myHybrid. getGasLevel()); // Print fuel remaining
System. out. println(myHybrid. getMileage()); // Print total miles driven
myHybrid. addGas(5); // Tank 5 gallons
myHybrid. drive(90); // Drive 90 miles
System. out. println(myHybrid. getGasLevel()); // Print fuel remaining
System. out. println(myHybrid. getMileage()); // Print total miles driven

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
An endless cycle of creation and response on the internet is called
Answers: 1
question
Computers and Technology, 24.06.2019 13:20
3. ranga ramasesh is the operations manager for a firm that is trying to decide which one of four countries it should research for possible outsourcing providers. the first step is to select a country based on cultural risk factors, which are critical to eventual business success with the provider. ranga has reviewed outsourcing provider directories and found that the four countries in the table that follows have an ample number of providers from which they can choose. to aid in the country selection step, he has enlisted the aid of a cultural expert, john wang, who has provided ratings of the various criteria in the table. the resulting ratings are on a 1 to 10 scale, where 1 is a low risk and 10 is a high risk. john has also determined six criteria weightins: trust, with a weight of 0.3; quality, with 0.2; religious, with 0.1; individualism, with 0.2; time, with 0.1; and uncertainity, with 0.1. using the factor-rating method, which country should ranga select? why? (2 points)
Answers: 3
question
Computers and Technology, 24.06.2019 17:00
Aman travel 200m towards east< br /> from his house then takes left< br /> to turn and moves 200 m north< br /> find the displacement & distance.< br />
Answers: 3
question
Computers and Technology, 24.06.2019 18:00
Why is a multiview sketch drawinf different from other sketches like isometric, two point, and oblique
Answers: 1
You know the right answer?
Implement a class Car with the following properties:(IN JAVA) A car has a certain fuel efficiency (...
Questions
question
Mathematics, 09.01.2021 06:20
question
Mathematics, 09.01.2021 06:20
question
Mathematics, 09.01.2021 06:20
question
Mathematics, 09.01.2021 06:20
question
History, 09.01.2021 06:20
Questions on the website: 13722362