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
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...
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...
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...
Develop a Traceroute application in python using ICMP. Your application will use ICMP but, in order...
Develop a Traceroute application in python using ICMP. Your application will use ICMP but, in order to keep it simple, will not exactly follow the official specification in RFC 1739.. Below you will find the skeleton code for the client. You are to complete the skeleton code. The places where you need to fill in code are marked with #Fill in start and #Fill in end. Code from socket import * import os import sys import struct import time import...
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...
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...
***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,...