Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5.1 Lab 1 Note that you must complete the lab exactly as it is described to receive full credit. This includes proper capitalization and naming

5.1 Lab 1 Note that you must complete the lab exactly as it is described to receive full credit. This includes proper capitalization and naming of all variables and methods. Failure to follow directions will result in a loss of points. You are to define a class called Odometer that will be used to track fuel and mileage for an automobile. The class must meet the following specifications: The class should have fields to track the miles driven (called currentMileage) and the fuel efficiency of the vehicle in miles per gallon (called mpg). You must choose the appropriate access level for your fields. Both of these variables should be doubles . You must provide two constructors for your class. The first is a no parameter constructor that sets currentMileage to 0 and mpg to 30. The second takes in the initial mpg as a double, initializes the mpg to the passed in value and still sets currentMileage to O . You must include a method resets the odometer to zero miles. Name this method resetMileage . You must provide a setter method for setting the fuel efficiency. Name this method setMPG . You must include a method that takes in a number of miles as a double and adds it to the currentMileage. Name this method addMileage Finally, you must provide a method that returns the number of gallons of gasoline that the vehicle has consumed since the odometer was last reset. Name this method getFuelEfficiency Again, you must create use the proper access levels (ie., private or public) for all variables and methods, and you must implement your class exactly as described in order to receive full credit. You will use your IDE to write your solution and then upload it to ZyLabs for grading. Use Java as the programming language for the assignment

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

Students also viewed these Databases questions

Question

1. What physical and mental tasks does the worker accomplish?

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago