public getFuelLevel():double
retrieves fuel level in gallons
Precondition: fuel level is initialized
Postcondition: no change in state
Return: fuel level in gallons with decimal values
public getFuelTankSize():double
retrieves fuel level in gallons
Precondition: fuel level is initialized
Postcondition: no change is state
Return: fuel level in gallons with decimal values
public setUpTrip(double, double): void
Car's state is set to hold the speed of travel and distance to travel at that speed
Precondition: none
Postcondition: Car's state holds information on distance to travel and speed to travel
Parameters: Average Speed to be driven, Distance to drive
Develop and use an
driven in the drive() method. The algorithm must use a formula or multiple formulas ( as a
piecewise function) that gives proportionately poorer mileage when the Car is driven faster or
slower than its optimal speed. When a new Car object is instantiated, it is initialized with an
optimal speed variable. Your fuel usage algorithm should set limits on how poor of MPG your
car will get, i.e. set an arbitrary limit of 2 or 3 miles per gallon.
You may add other methods and fields as needed.
When a new Car object is created,
the car’s odometer is set to a random number between 0.0 and 5.99,
the car’s trip odometer is set to 0.0,
its best fuel economy (MPG) is set to a random number between 15.0 and 54.99,
its optimal speed is set to a random number between 45.0 and 64.99,
and its fuel tank size is set to a random number between 8 and 34.99 gallons.
Hint: Use “helper” methods to generate these random values.
Use Math.random( ) to generate your random numbers. Remember Math.random( )
generates a random double number value from 0.0 to but not including 1.0.
o So, to get a random number between 0.0 and 99.99 you must multiply the result
of Math.random( ) by 100.
o To get a random number between 5 and 15(excluding 15), subtract 5 from 15 to
get 10, multiply Math.random() by 10 then add 5.
o Example: If Math.random( ) produced 0.4584, multiplying it by 10 would produce
4.584. Then adding 5 would produce 9.584, which is a value between 5 and 15.
Since the new class Car inherits the .equals() and .toString() methods from the Java Object class,
you will need to overload the .equals( ) method and override the .toString( ) method.
Part 2:
After you are comfortable with the Car class, create a Garage class to store Cars. The Garage
object is an instantiation of a Garage class that contains “parking”, an array of the Car class. You
must use a Car[] not an ArrayList<Car> for the “parking” in the garage. You will use Car objects
to fill the garage. I will provide an algorithm for the CarGarageDriver class as a test driver to test
your Car and Garage classes.
The rules for the garage are:
The size of the garage is specified by the user.
The user may only use cars from the garage
A Car is removed from the Garage when a user retrieves a Car from the Garage.
The Car is returned to the Garage, after it is driven if it does not run out of fuel.
The user interacts with the Car object after the Car object is retrieved from the garage.
The program should not fail due to a user selection.
A car may only be refueled while in the Garage
The user may select to drive any car that is currently in the garage
The user is the only one that may request that a car be refueled(do not refuel a car
automatically)
After the user gets a Car, they set up the drive by entering in the average speed and the
driving distance.
See the Car methods above.
the driving distance is the round-trip distance from the garage and back again.
The driver program is only allowed to use the Car’s public methods listed above, and
those you create for the Garage class.
The user drives the car by telling that car to drive. Again, you may use menus to offer
options to the user. (See the attached example run of my CarGarageDriver
implementation.)
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Rules: Corner cases. By convention, the row and column indices are integers between 0 and n − 1, where (0, 0) is the upper-left site. Throw an IllegalArgumentException if any argument to open(), isOpen(), or isFull() is outside its prescribed range. Throw an IllegalArgumentException in the constructor if n ≤ 0. Unit testing. Your main() method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output). Performance requirements. The constructor must take Θ(n^2) time; all instance methods must take Θ(1)Θ(1) time plus Θ(1)Θ(1) calls to union() and find().arrow_forwardIN JAVA "New Employee Gross Salary Calculator" Write a method that accepts an employee's yearly salary and start date and calculates their gross salary from the provided start date up through the end of the year Employees always start on the first of the month Throw an IllegalArgumentException if the provided start date is not the first of the month Employees qualify for a 3% pay raise 3 months after their start date and another 6% 3 months after that Use appropriate data typearrow_forwardIn Java Write a Fraction class that implements these methods:• add ─ This method receives a Fraction parameter and adds the parameter fraction to thecalling object fraction.• multiply ─ This method receives a Fraction parameter and multiplies the parameterfraction by the calling object fraction.• print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.)• printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)• Separate accessor methods for each instance variable (numerator , denominator ) in theFraction classProvide a driver class (FractionDemo) that demonstrates this Fraction class. The driver class shouldcontain this main method : public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print(); System.out.println("Enter numerator; then denominator."); d = new…arrow_forward
- this is the information that has to be hard-coded: # hard-coded calls jim = User(first_name='Jim', last_name='Bob', user_id=1000, last_login='June 12, 1998', password='password123') jim.describe_user() jim.greet_user() joe = User('Joe', 'Bob', 1001, 'July 4, 2001', 'babygirl') joe.greet_user() joe.describe_user()arrow_forward1) Take the supplied cars_db.sql and create your Cars database (you will have to create the Cars database first, then execute the .sql file from within Netbeans). 2) Implement a program that has the same general user interface as the SimpleSchoolData presented in class. 3) Implement two classes, CarsDisplay which displays the above application, and implement a class named CarQueries that contains the prepared statements to execute the queries. (Java) This is the cars_db.sql DROP TABLE Cars; CREATE TABLE Cars ( CarID INT NOT NULL GENERATED ALWAYS AS IDENTITY, CarMake VARCHAR (10) NOT NULL, CarModel VARCHAR (15) NOT NULL, CarYear VARCHAR (4) NOT NULL, CarMileage DECIMAL (6) NOT NULL ); INSERT INTO Cars (CarMake,CarModel,CarYear,CarMileage) VALUES ('Honda','Civic','1998',135647), ('Honda','Accord','2009',46877), ('Nissan','Pickup','1997',235444);arrow_forwardInclude an inner listener class to handle the events from the Save Record button. WhenSave Record button is clicked, new customer record is inserted into the table named“CUSTOMER” and display a message “New Customer Record Inserted” in a dialog box.Include another anonymous inner listener class to handle the events from the Reset button.When Reset is clicked then clear all the text fields and place the cursor in the first text fieldto allow the user to re-enter the correct values and Write a code that includes an exception handler that deals with duplicate records (e.g. sameCustomer ID.) and database error (e.g. Error establishing a database connection).arrow_forward
- A WriteOnly attribute may be implemented automatically. True vs. Falsearrow_forwardclass dvd: def __init__(self, title, director, producer, release_date, duration, dvd_id): self.title = title self.director = director self.producer = producer self.release_date = release_date self.duration = duration self.dvd_id = dvd_id def get_title(self): return self.title def get_director(self): return self.director def get_producer(self): return self.producer def get_release_date(self): return self.release_date def get_duration(self): return self.duration def get_dvd_id(self): return self.dvd_id def __repr__(self): return "Movie Name: "+self.title+", \nDirector : "+self.director+", \nProducer : "+self.producer+", \nRelease Date : "+str(self.release_date)+", \nDuration : "+str(self.duration)+", \nDVD ID : "+str(self.dvd_id) class customer: def __init__(self, name, customer_id): self.name = name self.dvds=[] self.customer_id = customer_id…arrow_forwardBlackjack is a card game sometimes called Twenty-One. The object of Blackjack is to have a hand of cards whose score is 21, or as close to this as possible. A player whose hand exceeds a score of 21 is said to have bust and loses. A hand in Blackjack is scored as follows: • Cards 2 to 10 are given their card value as points (i.e. 2 to 10 points). • Face cards, the Jack, Queen and King, are all worth 10 points. • The Ace card is worth 11 points, or 1 point if doing so prevents the player from going bust. For example, if a player's hand has three Aces and a 6, one of the Aces will be worth 11 points, while the other two will be worth 1 point, making the score for the hand 19 (11 + 1 + 1 + 6). If all three Aces are worth 11, then the score for the hand would be 39 (11 + 11 + 11 + 6) and the player would be bust. Similarly, if two of the Aces are worth 11 points, then the score of the hand would be 29 (11 + 11 + 1 + 6) and the player would also be bust. Complete the blackjack_hand_score()…arrow_forward
- ScenarioI want to create an INDEXCEPTION value of the unique vowels and unique consonants that the name that was given to you can create.InputA string of the name that was GIVEN TO YOU. CASE SENSITIVE.ProcessStep 1: For every unique vowel of a name, you need to get the first index of that vowel from the original string.Step 2: For each vowel index you get from step 1, you will get the unique consonant from that position. if the index is out of scope of the consonant array, ignore that vowel index.Step 3: For each unique consonant that you get from step 2, you need to get the first index of that consonant from the original string.Step 4: Get the value of indexception by adding all index you get from step 3.OutputTO BE DISPLAYED- 2 lists that consists of unique vowels and unique consonants- The vowel, the vowel index, the consonant, the consonant indexFINAL OUTPUT- The total indexception value of the name that was given to you.arrow_forwardDesign a JavaScript+Jquery application to read the PAN Number and Name of an Employee. If the PAN Number does not contain exactly 10 characters and if the Name of the Employee is empty, throw an llegalArgumentException. If the PAN Number contains any character other than digits and alphabets(Vice versa), throw a NoSuchElementException. Considering the PAN number starts with 0 to 9 position, check for Oth to 4th (including 4th position) to be alphabets, check for 5th to 8th position (including 5th &8th position) of the PAN Number to be digit, again 9th position must be alphabet and also 4th position of the PAN Number should be the First Letter of the employee's Name. If all the cases are valid for PAN Number print the message 'valid else 'invalid. Change the Color of exception messages using JQuery.arrow_forwardModify it and should pass 2 testcase if not then Thumbsdown.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY