Question

In Java Please, Use your language's Priority Queue. Make a priority queue to represent customers being...

In Java Please, Use your language's Priority Queue. Make a priority queue to represent customers being served at the Department of Motor Vehicles.

  • Start with 100 customers in a List.
  • In a loop, generate a priority for each customer (1-5)
  • In a second loop, add the users to a priority queue
  • Print the List and the Priority Queue

Homework Answers

Answer #1

SOURCE CODE:

import java.util.*;
import java.lang.*;
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc= new Scanner(System.in);
System.out.println("enter the number of customers");
int numOfCusomers=sc.nextInt();
List<String> customersList = new ArrayList<String>(); //list
while(numOfCusomers!=0)
{
customersList.add(sc.nextLine());
numOfCusomers--;
}
  
System.out.println("Printing List: "+customersList);
PriorityQueue<String> pq = new PriorityQueue<>(); // priority queue
pq.add("z"); //
pq.add("y");
pq.add("x");
System.out.println("PriorityQueue: " + pq);
}
}

OUTPUT:

enter the number of customers
4
lucky
ram
raju
hema
Printing List: [,lucky, ram, raju, hema]
PriorityQueue: [x, z, y]



Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
IN JAVA LANGUAGE - Priority Queue Application Use your language's Priority Queue. Make a priority queue...
IN JAVA LANGUAGE - Priority Queue Application Use your language's Priority Queue. Make a priority queue to represent customers being served at the Department of Motor Vehicles. Start with 100 customers in a List. In a loop, generate a priority for each customer (1-5) In a second loop, add the users to a priority queue Print the List and the Priority Queue
Write in Java (Not Javascript) Provide an implementation of priority queue using double-ended doubly linked lists....
Write in Java (Not Javascript) Provide an implementation of priority queue using double-ended doubly linked lists. Recall that double-ended means keeping first and last references and doubly linked feature allows us to go backwards, using a prev reference at each Link. Also, note that the greater the number, the lower the priority. For instance, 2 is of higher priority compared to 5. Specifically, write a class LinkedListPriorityQ which implements the priority queue methods: boolean isEmpty() void enqueue(int item) int dequeue()...
****NEED CODED IN C++**** You are to generate a list of customers to serve based on...
****NEED CODED IN C++**** You are to generate a list of customers to serve based on the customer’s priority, i.e. create a priority queue/list for a local company. The company has been receiving request and the request are recorded in a file, in the order the request was made. The company processes each user based on their priority, the highest priority which is the largest number. Priorities of equal value are first come first served as listed in the input...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
This is in java and it is building a Binomial Queues. The packaging division at Complex...
This is in java and it is building a Binomial Queues. The packaging division at Complex Circuits Inc. is assigned the task of packing integrated circuit chips into boxes for shipment. Boxes come in different sizes and the capacity of a box (in terms of number of chips) is an exponent of 2, i.e., boxes can hold 1, 2, 4, 8, 16….chips. Each chip has the following parameters: weight – a positive, real number in the range of 0-1 id...
Java please. Need to use a linked list only. Many people have used pulling petals off...
Java please. Need to use a linked list only. Many people have used pulling petals off roses and tossing them in the air to determine if someone loves them or not. Your sister wants to use roses to determine which one of several suitors she will let take her to the prom. A linked list can be used to represent the prom date suitors. Write a program to simulate her decision and determine her prom date. The simulation will work...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do...
Code in Java SAMPLE PROGRAM OUTPUT Because there are several different things your program might do depending upon what the user enters, please refer to the examples below to use to test your program. Run your final program one time for each scenario to make sure that you get the expected output. Be sure to format the output of your program so that it follows what is included in the examples. Remember, in all examples bold items are entered by...
Facts: Your firm produces and leases vehicles while reimbursing customers for the cost of fuel of...
Facts: Your firm produces and leases vehicles while reimbursing customers for the cost of fuel of these vehicles. Each customer pays you $2,000 a year to operate a vehicle for ten years. Over the life of a vehicle, the customer drives 20 miles a day for 300 days a year for ten years before scrapping the vehicle (for 60,000 miles in total). The price of gas is now $2 a gallon. The steel vehicle consumes 0.04 gallons per mile (or...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...