Question: Please answer these problems, thank you! This lab uses a series of classes that compare the cost of travel by plane, train and auto from

 Please answer these problems, thank you! This lab uses a seriesof classes that compare the cost of travel by plane, train andauto from Rochester to some other destination. An interface is required and

Please answer these problems, thank you!

This lab uses a series of classes that compare the cost of travel by plane, train and auto from Rochester to some other destination. An interface is required and input is provided through command line arguments Exercise 1 - The cost of car travel (3 points) Step 1: Creating the interface Create an interface, Travelcost, that has the following characteristics A constant double AGENT FEE value in US dollars ($'s) of 10.00 An abstract method getDuration that returns a double trip length in hrs An abstract method getTotalcost that returns a double trip cost in $'s An abstract method getLodgingcost that returns a double lodging cost in $'s An abstract method getDestination that returns a String destination An abstract method tostring that returns a string formatted by string.format () Step 2: Create a class, CarTravelcost, with the characteristicS Attributes are trip distance int numMiles, nightly lodging cost double hotelcost and trip destination string destination A normal accessor for destination A constructor that accepts and updates all the attributes getDuration returns: numHours- (double) numMiles/65, (uses car speed of 65 mph) The getLodgingcost ) returns: numDays*hotelcost. numDays, which is the number of days on the road, is calculated as getDuration )/8.0 (8 hours of driving per day). There is no need to include fractional days as a whole day (why?); the Math.floor ) method will help getTotalCost ) returns: (numMiles0.45) +getLodgingCost (O +AGENT FEE This represents a mileage allowance of 45 cents per mile plus lodging A tostring method returns: destination, getDuration) and getTotalCost () formatted by String.format ) (see example below) Step 3: Create a test class , TestCarTravelCost, that takes in three command line arguments number of miles, hotel cost per night and destination. Issue an error message if there are not three arguments: ERROR: Invalid number of command line arguments. All data conversions should be done in the test class (e.g. string to double). If there is a valid number of arguments then Instantiate an object of the carTravelCost class using the three arguments Print out the tostring Sample Output Lab12 Interfaces Key- bash-80x24 Janeway: Lab12_Interfaces Key jim$ java TestCarTravelCost 400 Boston ERROR: Invalid number of command line arguments Janeway: Lab12_Interfaces Key jim$ java TestCarTravelCost 400 200 Boston Car travel to Boston will take 6.15 hours and cost $ 190.00 Janeway: Lab12 Interfaces Key jim$

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!