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
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...
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,...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import java.io.*; //This imports input and output (io) classes that we use 3 //to read and write to files. The * is the wildcard that will 4 //make all of the io classes available if I need them 5 //It saves me from having to import each io class separately. 6 /** 7 This program reads numbers from a file, calculates the 8 mean (average)...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this...
Please answer in JAVA IDS 401 Assignment 4 Deadline In order to receive full credit, this assignment must be submitted by the deadline on Blackboard. Submitting your assignment early is recommended, in case problems arise with the submission process. Late submissions will be accepted (but penalized 10pts for each day late) up to one week after the submission deadline. After that, assignments will not be accepted. Assignment The object of this assignment is to construct a mini-banking system that helps...
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT