(a) Develop a Java program to implement the transport hierarchy shown below. The Vehicle class should contain a getDateTime method to get the date and time of the last service in the form of calendar date and time and a getEntertainment method to get the vehicle entertainment e.g. radio, CD.

Each TwoWheelVehicle should contain a method getSpeed to calculate the speed of the two-wheel vehicle.

Each FourWheelVehicle should have methods getSpeed and getSeats to calculate the speed and seat capacity, respectively, of the four-wheel vehicle.

Write a program that creates one object of each of the concrete classes and create an array with references to all of these objects.

The program should print a text description of the object to which each array element refers.

Also, in the loop that processes all the vehicles in the array, determine whether each vehicle is a TwoWheelVehicle or a FourWheelVehicle.

If a vehicle is a TwoWheelVehicle, display its speed and how many times slower it is than the slowest FourWheelVehicle.

If a vehicle is a FourWheelVehicle, display its speed and seat capacity. It should also indicate the date and time in the form of elapsed days, hours, minutes and seconds since the last service.

(b) Develop a multi-threaded Java application as described below Five Data Centre job candidates take part in a data entry test on a 480 minute (8 hour) long day. Each candidate has different abilities:

  • Johns data entry speed is 260 lines per minute and he takes a rest every 30 minutes
  • Jamess data entry speed is 210 lines per minute and he takes a rest every 60 minutes
  • Anns data entry speed is 190 lines per minute and she takes a rest every 70 minutes
  • Marys data entry speed is 220 lines per minute and she takes a rest every 50 minutes
  • Liams data entry speed is 150 lines per minute and he takes a rest every 100 minutes

Rest times are 10 minutes for all job candidates.

(i) Write a multithreaded Java application to simulate a typical days data processing of 215 forms of 400 lines. Display a message in the terminal when each candidate has finished the test.

(ii) Create a job candidate class. The constructor accepts two integers for data entry speed and rest frequency, a reference to a rest object and a String for its name. The job candidate class should also have members that store a line count and duration in minutes. It should stop once the test is finished (i.e. after 480 minutes).

(iii) The area for resting can only be occupied by one job candidate at a time and it is occupied at the start of the test for 5 minutes. This will require synchronisation between threads and the use of locks. If a job candidate needs to take a rest but another candidate is already in the rest area they must skip their rest until their next scheduled one. As a result, their performance suffers and their throughput reduces by 50% until they have the opportunity to break again.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.