Question: QUESTION 2 (10 marks) a) Given the following Java application program segment, draw the diagram of Q after the code segment is executed. Label the

QUESTION 2 (10 marks) a) Given the following Java application program segment, draw the diagram of Q after the code segment is executed. Label the front and rear position of the diagram public class testo public static void main(String 11 Queue - new Queue: Object front Q.enqueue loreen Q.enqueue("blue") Q.dequo) Q.enqueue ("red"); front - Q.getFront 0.dequeue (1.5 marks) b) Given the following Queue and vehicle ADT classes below: elasa Vehicle private String vehicle: //Ixora, Myvis, X50 private String vehicletype //MPV. Sedan, SUV private String vehicleRegistrationDate/ddnmyyyy private double vehiclePrice //RM40000, M190000 Definition of other methods including normal constructor, mutators, accessors and tostring). class Queve publie Queve) public void enqueue Vehicle data) publie Vehicle daqueue -> public boolean Lapty> - > RSWZ Used Car company uses a system to store and keep track of its used car's record by using the queue data structure. Assume that the data have been stored into a queue named queue Vehicle, answer the following questions. i. Find and display how many used cars were registered in the year 2017. (Note: In order to avoid data foss, use a temporary queue to store the information.) (4.5 marks) Move all Exora cars which priced less than RM170,000.00 into queueExora while the other Exora cars remain in the original queue. (4 marks) QUESTION 2 (10 marks) a) Given the following Java application program segment, draw the diagram of Q after the code segment is executed. Label the front and rear position of the diagram public class testo public static void main(String 11 Queue - new Queue: Object front Q.enqueue loreen Q.enqueue("blue") Q.dequo) Q.enqueue ("red"); front - Q.getFront 0.dequeue (1.5 marks) b) Given the following Queue and vehicle ADT classes below: elasa Vehicle private String vehicle: //Ixora, Myvis, X50 private String vehicletype //MPV. Sedan, SUV private String vehicleRegistrationDate/ddnmyyyy private double vehiclePrice //RM40000, M190000 Definition of other methods including normal constructor, mutators, accessors and tostring). class Queve publie Queve) public void enqueue Vehicle data) publie Vehicle daqueue -> public boolean Lapty> - > RSWZ Used Car company uses a system to store and keep track of its used car's record by using the queue data structure. Assume that the data have been stored into a queue named queue Vehicle, answer the following questions. i. Find and display how many used cars were registered in the year 2017. (Note: In order to avoid data foss, use a temporary queue to store the information.) (4.5 marks) Move all Exora cars which priced less than RM170,000.00 into queueExora while the other Exora cars remain in the original queue. (4 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
