subject
Advanced Placement (AP), 23.12.2020 14:00 Lilyy1k

Can someone help? You are going to create a Car class to simulate how far a car can drive on a road trip. To do this, you will need to complete both the Car and the CarTester classes.

For the Car class, you will use the following variables and methods:

Instance Variables:

private double efficiency // this is miles per gallon
private double gas
private double tankCapacity
private double totalMilesDriven
Constructor:

public Car(double carEfficiency, double carTankCapacity)
Methods:

* public void addGas()- this method should fill the car with gas up to the tank capacity. The method should print `Filling up ...`

* public void addGas(double amount) - This should add amount to the tank. If the amount is greater than the capacity, set the gas to the tank capacity. The method should print `Adding gas ...`

* public double getTotalMilesDriven() - returns the number of miles the car has driven

* public void drive(double distance) - checks if car can drive that number of miles, and then adds miles to totalMilesDriven and subtracts the amount of gas needed to go those miles. The method should print `Driving [distance]` or, if the distance is too far, it should print `Can't drive [distance]. That's too far!`

* public boolean canDrive (double distance) - returns true if the car has gas

* public double milesAvailable() - returns how many more miles the car could drive

* public double getGas() - returns the amount of gas left
In creating both the Car and CarTester, be sure to check the sample output to guide your design considerations. You will need to have a conditional statement in the drive method to determine if you can drive the correct distance.

Also, make sure you check that you don’t over fill the gas tank!

Sample Output:
Filling up ...
Miles available: 300.0
Driving 100.0
Miles available: 200.0
Adding gas ...
Miles available: 260.0
Can't drive 1000.0. That's too far!
Driving 200.0
Gas remaining: 3.0
Total Miles Driven: 300.0

ansver
Answers: 2

Another question on Advanced Placement (AP)

question
Advanced Placement (AP), 22.06.2019 07:00
Asmall internet mail-order company keeps track of the number of orders it fills per day for many years and determines that the distribution of the variable "orders filled per day" is right-skewed and has the following five-number summary: minimum = 20 q1 = 32 median = 46 q3 = 63 maximum = 80 suppose we take random samples of size 40 from this distribution and calculate the range for each of our samples. (i cant put in the graph, but its approximately normal with center between 56 and 57, with a range of 53 to 60). a) there are two dots on the graph at 53. explain what these values represent. b) is the sample range an unbiased estimator of the population? use the dotplot above to justify your answer.
Answers: 1
question
Advanced Placement (AP), 23.06.2019 01:20
John locke wrote that if the people of a country believe their government is unjust or abusing power, they have a right to overthrow it. which founding principle does his statement support? natural rights limited government republicanism social contract
Answers: 1
question
Advanced Placement (AP), 23.06.2019 18:30
An object accelarates from rest to a velocity of 2.4m/s over a distance of 16m what was its accelaration
Answers: 1
question
Advanced Placement (AP), 25.06.2019 09:10
Describe one of your personality traits that you believe to be highly heritable and another trait that seems to be much less so. provide reasons for your answer, and explain why you would expect genetics to exert a greater impact on some personality traits than on others. 10. discuss at least 3 cultural/environmental factors that may influence behavior.
Answers: 3
You know the right answer?
Can someone help? You are going to create a Car class to simulate how far a car can drive on a road...
Questions
question
Mathematics, 03.07.2020 01:01
question
Mathematics, 03.07.2020 01:01
question
Advanced Placement (AP), 03.07.2020 01:01
Questions on the website: 13722366