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 09:40
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
question
Computers and Technology, 22.06.2019 13:00
Which part of the cpu accepts data?
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Write and test a python program to find and print the largest number in a set of real (floating point) numbers. the program should first read a single positive integer number from the user, which will be how many numbers to read and search through. after reading in all of the numbers, the largest of the numbers input (not considering the count input) should be printed.
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, 10.10.2021 18:10
question
Mathematics, 10.10.2021 18:10
question
Mathematics, 10.10.2021 18:10
question
Geography, 10.10.2021 18:10
question
Mathematics, 10.10.2021 18:10
question
Mathematics, 10.10.2021 18:10
question
Mathematics, 10.10.2021 18:10
question
Biology, 10.10.2021 18:10
Questions on the website: 13722367