Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create Car class using information below Instance Variables private String carModel; // Car Model (e.g., Honda Civic) private double milesPerGallon; // Car's average mpg rating

Create Car class using information below

Instance Variables

private String carModel; // Car Model (e.g., "Honda Civic")

private double milesPerGallon; // Car's average mpg rating (e.g., 28.5)

private double gasTankSize; // Car's gas tank size, in gallons (e.g., 12.0)

private double gallonsInTank; // Gas (in gallons) remaining in gas tank (e.g., 9.2)

image text in transcribed

image text in transcribed

Car API Function (parameters) Description Default Constructor Car(String m, double mpg, double Overloaded constructor which initializes the instance tank Size, double galLevel variables String getCarModel Returns a string representing the car model void set CarModel(String m) Sets the can's model to m double get Miles Per Gallon Returns a double representing the cars mpg ratin void setMiles Per Gallon (double mpg) Sets the cars miles-per-gallon rating to mpg. double getGasTanksize() Returns a double representing the car's tank size in gallons void SetGasTankSize(double tankSizeD Sets the car's tank Size to tanksize (gallons). Returns a double representing the number of gallons in double getGallonslnTank() the car's tank void setGallonslnTank(double galLevel Sets the car's tank level to galLevel. If galLevel is bigger than the tank size, then automatically set the number of gallons in the tank to the tank size. boolean triveDistance(double miles Simulates the car driving some distance, represented by the miles parameter. This function will appropriately "burn" the proper amount of gas in the tank. If there is enough gas to drive a distance of miles, this function should print out how many gallons of fuel were just burnt AND how many more miles can be driven before running out of fuel. Return true to indicate a successful drive. If there is not enough gas in the tank to drive a distance of miles without running out of fuel, the function should print out a statement indicating how many miles were traveled before running out of fuel. Return false to indicate a failed drive. NOTE: See Sample output for print formatting

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

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions