subject

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: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
What is the foundation for proper monitoring, load balancing and routing in distributed systems
Answers: 3
question
Computers and Technology, 22.06.2019 12:20
Usually, when we sniff packets, we are only interested certain types of packets. we can do that by setting filters in sniffing. scapy’s filter use the bpf (berkeley packet filter) syntax; you can find the bpf manual from the internet. set the following filters and demonstrate your sniffer program again (each filter should be set separately): (a) capture only the icmp packet. (b) capture any tcp packet that comes from a particular ip and with a destination port number 23. (c) capture packets comes from or to go to a particular subnet. you can pick any subnet, such as 128.230.0.0/16; you should not pick the subnet that your vm is attached to.
Answers: 3
question
Computers and Technology, 23.06.2019 04:40
The narrative structure of the popular movies can be broken down into
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
You know the right answer?
Project 16A- Gas Mileage package: mileage
Class: 2 files - Main. java, and Automobile. java
Questions
question
English, 03.03.2021 22:50
question
SAT, 03.03.2021 22:50
question
Mathematics, 03.03.2021 22:50
question
Spanish, 03.03.2021 22:50
question
Mathematics, 03.03.2021 22:50
question
Mathematics, 03.03.2021 22:50
question
Mathematics, 03.03.2021 22:50
question
French, 03.03.2021 22:50
question
Mathematics, 03.03.2021 22:50