Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Vehicle Class Project

Create a New Java Project called YourLastNameVehicleClass.

Write a class named Vehicle that has the following fields:

make: a String that holds the make of the car

model: a String that holds the model of the car

tankSize: an int that holds the car's gas tank size in gallons

NOTE: The Vehicle Class 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's make, model, and tankSize fields, respectively.

Accessors: appropriate accessor methods should get the values stored in an object's make, model, and tankSize fields. 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

Demonstrate the class in a program that creates a Vehicle object, and then calls the distance method. Be sure to display the make, model, tankSize, and distance. The distance should be displayed with no more than three (3) decimal places. Each output should be labeled clearly.

PROGRAMMING GUIDELINES: A programming assignment will be assigned a grade of 0 if it fails to compile. Each program must not contain any spelling errors in the program output or points will be deducted. Each program must contain a comment section (or points will be deducted) that indicates the following: 1. Student Name 2. Program Name 3. Short Program Description 4. Due Date Programs should use appropriate spacing and indentation, in order to increase readability. Programs should only be completed in Eclipse. Use comments for clarification throughout your programs. Use meaningful variable names. Subdivide your program into mini-sections. For more difficult programs, this will make it easier to detect both syntax and logical errors. Naming Convention for mutator methods: set + fieldname (i.e. setName) Naming Convention for accessor methods: get + fieldname (i.e. getName)

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_2

Step: 3

blur-text-image_3

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago