Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Do in java and have all three classes included There is a car rental company that would like to update their system with a new
Do in java and have all three classes included
There is a car rental company that would like to update their system with a new feature that can check if current fuel level is sufficient for the customer to drive to the destination and keep track of the cars if they need to be refilled after several trips. We read the instructions from the standard input (console/keyboard). The program will start from the main method in the Main. java file. Each object from the class CarModel is supposed to represent a certain car model with the given name, fuel economy, and tank capacity. Each object from the class Car is an instance of a car from a given model and with a certain plate number. The cars can go on a trip, and they will consume some fuel based on the length of the trip and the fuel economy of their models. Cars can be refilled after they run out of fuel. Input As shown in the following examples, each line of input is a command with multiple space-separated tokens: - If the line starts with "MODEL," then it is defining a new car model, and it will be followed by the model name (comprised of English characters or digits with no spaces in between), fuel economy (floating point value), and tank capacity (floating point value). - If the line starts with "CAR," then it defines an instance of a car, and it will be followed by the model name and the plate number (plate number is always a positive integer smaller than 999999). - If the line starts with "TRIP," then it will be followed by a plate number and given distance in kilometers. In this case, the car will burn some gas and the program should output whether the trip was successful (see the output sample for details). - If the line starts with "REFILL," then it will be followed by a plate number. In this case the fuel tank of the corresponding car should be refilled to be full. - If "FINISH" is written on a line, it signals the end of the input. - You can assume that the maximum number of commands is 100 . This can help you in creating appropriate arrays (you can also use ArrayLists to handle a case where you do not know the size of an array a priori). Examples Here is a different example with the use of REFILL command. Processing Your program should be able to keep track of the trips to see if the trip for the car is successful or not. Assume every car has a full tank of fuel at the beginning of its first trip. Fuel consumption is calculated by 100.0distance fuel economy Apart from keeping track of the trips, your program should also have a refill function with the following assumptions. - Your program should accommodate the input with some leading spaces and following spaces if the inputs have some extra spaces. - You can assume that we will not have multiple "MODEL" commands with the same model name. Also, we will not have multiple "CAR" commands with the same plate number. - You can assume that the input is always in the correct format. Also, there are no "TRIP" or "REFILL" commands where the plate number is not defined before. Also, there is no "CAR" command where its model name is not defined before. - Input starting with "REFILL" means the gas tank of the corresponding car should be refilled to be full. - The commands are run line-by-line so the order of the input (and output) matters. - You are allowed to create new classes, use the given classes, and modify the given classes. Your final main () function should be defined within the class Main. Output If the current fuel level for the car with plate number is enough for a trip, it will output the trip completed successfully for the car with corresponding plate number; otherwise, print out not enough fuel for the car with corresponding plate number. All output should be to the console, and each line is terminated by a newline. The output format is shown in the above examplesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started