Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a New Java Project called YourLastNameVehicleClass . Write a class named Vehicle that has the following fields: make : a String that holds the

Create a New Java Project calledYourLastNameVehicleClass.

Write a class namedVehiclethat has the following fields:

make: aStringthat holds the make of the car

model: anStringthat holds the model of the car

tankSize: anintthat holds the car's gas tank size in gallons

NOTE: TheVehicleClass is a new class within your project. It should be defined as a separate file. This does not affect the name of your Java Project above.

In addition, the class should have the following constructor and other methods.

Constructor: accepts the car's make, model, and tankSize as arguments. These values should be assigned to the object'smake,model, andtankSizefields, respectively.

Accessors: appropriate accessor methods should get the values stored in an object'smake,model, andtankSizefields. Be sure to use the required naming convention for all accessor methods from the Programming Guidelines.

distance: This method should calculate and display the distance the vehicle can travel on one tank of gas when driven in town and when driven on the highway.Assume the vehicle averages 25 miles per gallon when driven in town and 38.5 miles per gallon when driven on the highway.

Hint: The following formula can be used to calculate the distance:

Distance = Number of Gallons X Average Miles per Gallon

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What is the purpose of a comfort letter? Discuss.

Answered: 1 week ago

Question

Do you think physicians should have unions? Why or why not?

Answered: 1 week ago