Question

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

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 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
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()...
Generate 100 random numbers and add them to a stack and a queue, after print out...
Generate 100 random numbers and add them to a stack and a queue, after print out the content from both stack and queue, sort the data from both in ascending order, then print out again, after being sorted, and go through both the stack a queue and remove an element one at a time till empty then print out a message saying its empty. print out how much time it took to do this process, basically compare the stack and...
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....
****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...
IN JAVA Language- Singly Linked List Implementation Implement a Linked List in your language. Use your...
IN JAVA Language- Singly Linked List Implementation Implement a Linked List in your language. Use your Can class. You need to create a driver that makes several Can objects and places them in alphabetical order in a list. Identify the necessary methods in a List Linked implementation. Look at previous Data Structures (stack or queue) and be sure to include all necessary methods. NOT USE your language's Library List . You will receive zero points. Write a LinkedList class. Include...
Create and use an enumeration create an enumeration and use it in a test application. 1....
Create and use an enumeration create an enumeration and use it in a test application. 1. Import the project named ch13 ex 2 Enumeration that's in the ex starts folder, 2. Create an enumeration named CustomerType. This enumeration should contain constants that represent three types of customers: retail. trade, and college. Use an enumeration 3. open the Customer Type App class. Then, add a method to this class that returns a discount percent C10 for retail. 30 for trade. and.20...
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and...
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and make a java program for your bank. However, there is another type of customer that may not have money in the bank and may not in fact have a back account with this bank at all, but may have a loan here. Make another class in the application you are making called CarLoan. Carloan's should have a name, amount owed, a rate, and a...
Language: JAVA(Netbean) Using a hash set to do a Monte Carlo analysis of the birthday paradox....
Language: JAVA(Netbean) Using a hash set to do a Monte Carlo analysis of the birthday paradox. The paradox states that the odds of 2 people in a group sharing a birthday is surprisingly high. A Monte Carlo analysis is using random numbers to simulate actual probable outcomes. Test your code for various numbers of people. Here is pseudo code of the algorithm: Set number of collisions to zero Loop (10 to100 by 10)    Loop:       Generate a birthday. (use...
In JAVA Find the code for sorts in your language some where online. You will copy...
In JAVA Find the code for sorts in your language some where online. You will copy code from the internet (with citation!) and modify it to test. Make a random array of integers, then perform each search on them. LINEAR SEARCH Write a linear search method to find a number in the list. Call this before each of your sort methods. Include a comment explaining how Linear Search works, when to use it, when you cannot. BINARY SEARCH Write a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT