1. Homepage
  2. Programming
  3. CSCI 1110 Assignment 2: Car Rental with Refill and Trip Comparison

CSCI 1110 Assignment 2: Car Rental with Refill and Trip Comparison

Engage in a Conversation
CanadaDalhousie UniversityCSCI 1110Computer Science I and IIJavaCar Rental with RefillOOPObject-oriented ProgrammingCar Rental with Trip Comparison

CSCI 1110: Assignment 2 CourseNana.COM

Due: 2:00 pm, Monday, February 27, 2023 CourseNana.COM

The purpose of this assignment is to reinforce your understanding of object-based programming and to problem-solve using objects, classes, and nested loops. For this problem you will be provided with sample tests in Codio. All input is done via the console and all output is to be done to the console as well. You must submit your assignment via Codio, and you can test it by submitting your code. Note: for this assign- ment you are expected to install and use an IDE (other than Codio) to develop your code. Please see How-To videos in the How-To Tutorial Section of our Brightspace page on how to install an IDE. This assignment is divided into two problems, where each problem subsumes the previous one. Hence, if you complete Problem 2, you will have also completed Problem 1. CourseNana.COM

Problem 1: Car Rental with Refill CourseNana.COM

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/key- board). 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. CourseNana.COM

Input CourseNana.COM

As shown in the following examples, each line of input is a command with multiple space-separated to- kens: CourseNana.COM

  • 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 CourseNana.COM

MODEL Camry 6.5 58 CourseNana.COM

Trip completed successfully for #1111 CourseNana.COM

MODEL Civic 7.5 52 CAR Camry 1111 CAR Camry 2222 CAR Civic 3333 CAR Civic 4444 TRIP 1111 350 TRIP 2222 350 TRIP 3333 350 TRIP 4444 350 TRIP 1111 350 TRIP 2222 350 TRIP 3333 350 TRIP 4444 350 FINISH CourseNana.COM

Trip completed successfully for #2222 CourseNana.COM

Trip completed successfully for #3333 CourseNana.COM

Trip completed successfully for #4444 CourseNana.COM

Trip completed successfully for #1111 CourseNana.COM

Trip completed successfully for #2222 CourseNana.COM

Not enough fuel for #3333 CourseNana.COM

Not enough fuel for #4444 CourseNana.COM

Here is a different example with the use of REFILL command. CourseNana.COM

Input Output CourseNana.COM

MODEL X5 10 68 CourseNana.COM

CAR X5 787878 CourseNana.COM

TRIP 787878 500 CourseNana.COM

TRIP 787878 500 CourseNana.COM

TRIP 787878 10 CourseNana.COM

REFILL 787878 CourseNana.COM

TRIP 787878 500 CourseNana.COM

FINISH CourseNana.COM

Trip completed successfully for #787878 CourseNana.COM

Not enough fuel for #787878 CourseNana.COM

Not enough fuel for #787878 CourseNana.COM

Trip completed successfully for #787878 CourseNana.COM

Processing CourseNana.COM

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 CourseNana.COM

???????? × ???? ???????. 100.0 CourseNana.COM

Apart from keeping track of the trips, your program should also have a refill function with the following assumptions. CourseNana.COM

  • 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 “RE- FILL” 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. CourseNana.COM

Output CourseNana.COM

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 examples. CourseNana.COM

Problem 2: Car Rental with Trip Comparison CourseNana.COM

Extend your program from Problem 1 to handle one more change. We build on Problem 1 and add the following commands to the set of possible commands. CourseNana.COM

Input CourseNana.COM

Based on the input of Problem 1, there is one additional function that we need to cover. If an input line starts with “LONGTRIPS,” then it will be followed by a plate number and a distance in kilometers (floating point). CourseNana.COM

Processing CourseNana.COM

Your program should perform the same task as stated in Problem 1. In addition, in the case of input line starting with “LONGTRIPS,” you will need to output the number of trips that were made successfully by the given car and were equal or longer than the given distance. See the example output for details. CourseNana.COM

Output CourseNana.COM

The output format is shown in the following examples. CourseNana.COM

Examples CourseNana.COM

MODEL Camry 6.5 58 CourseNana.COM

Trip completed successfully for #1111 CourseNana.COM

MODEL Civic 7.5 52 CAR Camry 1111 CAR Civic 4444 TRIP 1111 50 CourseNana.COM

TRIP 4444 50 CourseNana.COM

TRIP 1111 350 CourseNana.COM

TRIP 4444 350 CourseNana.COM

TRIP 1111 350 CourseNana.COM

TRIP 4444 350 CourseNana.COM

LONGTRIPS 1111 300 CourseNana.COM

LONGTRIPS 4444 300 CourseNana.COM

FINISH CourseNana.COM

Trip completed successfully for #4444 CourseNana.COM

Trip completed successfully for #1111 CourseNana.COM

Trip completed successfully for #4444 CourseNana.COM

Trip completed successfully for #1111 CourseNana.COM

Not enough fuel for #4444 CourseNana.COM

#1111 made 2 trips longer than 300 CourseNana.COM

#4444 made 1 trips longer than 300 CourseNana.COM

What to Hand In CourseNana.COM

This assignment must be submitted in Codio via the Brightspace page. CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Canada代写,Dalhousie University代写,CSCI 1110代写,Computer Science I and II代写,Java代写,Car Rental with Refill代写,OOP代写,Object-oriented Programming代写,Car Rental with Trip Comparison代写,Canada代编,Dalhousie University代编,CSCI 1110代编,Computer Science I and II代编,Java代编,Car Rental with Refill代编,OOP代编,Object-oriented Programming代编,Car Rental with Trip Comparison代编,Canada代考,Dalhousie University代考,CSCI 1110代考,Computer Science I and II代考,Java代考,Car Rental with Refill代考,OOP代考,Object-oriented Programming代考,Car Rental with Trip Comparison代考,Canadahelp,Dalhousie Universityhelp,CSCI 1110help,Computer Science I and IIhelp,Javahelp,Car Rental with Refillhelp,OOPhelp,Object-oriented Programminghelp,Car Rental with Trip Comparisonhelp,Canada作业代写,Dalhousie University作业代写,CSCI 1110作业代写,Computer Science I and II作业代写,Java作业代写,Car Rental with Refill作业代写,OOP作业代写,Object-oriented Programming作业代写,Car Rental with Trip Comparison作业代写,Canada编程代写,Dalhousie University编程代写,CSCI 1110编程代写,Computer Science I and II编程代写,Java编程代写,Car Rental with Refill编程代写,OOP编程代写,Object-oriented Programming编程代写,Car Rental with Trip Comparison编程代写,Canadaprogramming help,Dalhousie Universityprogramming help,CSCI 1110programming help,Computer Science I and IIprogramming help,Javaprogramming help,Car Rental with Refillprogramming help,OOPprogramming help,Object-oriented Programmingprogramming help,Car Rental with Trip Comparisonprogramming help,Canadaassignment help,Dalhousie Universityassignment help,CSCI 1110assignment help,Computer Science I and IIassignment help,Javaassignment help,Car Rental with Refillassignment help,OOPassignment help,Object-oriented Programmingassignment help,Car Rental with Trip Comparisonassignment help,Canadasolution,Dalhousie Universitysolution,CSCI 1110solution,Computer Science I and IIsolution,Javasolution,Car Rental with Refillsolution,OOPsolution,Object-oriented Programmingsolution,Car Rental with Trip Comparisonsolution,