Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:00, sdonachy7
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
image
Computers and Technology, 22.06.2019 17:00, ruddymorales1123
What allows you to create a wireless connection among your smart devices
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, woodpeckerdeejpe8wvh
How to launch an app: steps to be successful? launching an app is a great idea, but it’s not that easy as we supposed to think. the majority of mobile applications don’t generate revenue because companies aren’t ready to be competitive. referring to our experience in successfully building and launching apps we hope to you omit these difficulties. we are going to talk about ideas, marketing, testing your product, its development, distribution and support. you will learn 8 product launch stages to succeed.
Answers: 1
image
Computers and Technology, 23.06.2019 11:00, danielcano12281621
Sports and entertainment class, your goal is to increase attendance and make a profit for a game by getting your team on a winning track with total salaries less than $3,000,000
Answers: 3
Do you know the correct answer?
Implement a class Car with the following properties:(IN JAVA) A car has a certain fuel efficiency (...

Questions in other subjects: