Serious help needed. I need to make a stack the base data type and use that to implement the priority queue. It must also include an insert method and a removeMin method. Thanks, any help is appreciated
'
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Stack
public class Problem2 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
PriorityQueue<Entry> pq = new PriorityQueue<Entry>();
for (int i = 0; i<5; i++)
{
int a = scn.nextInt();
String b = scn.next();
pq.add(new Entry(a, b));
}
System.out.println("The output from the priority queue:");
for(int i = 0, c = pq.size(); i<c; i++)
{
System.out.println(pq.remove());
}
}
static class Entry implements Comparable<Entry> {
int k;
String v;
public Entry()
{
}
public Entry(int key, String value) {
k = key;
v = value;
}
public String toString() {
return ("Key " + k + " value " + v);
}
public int compareTo(Entry b) {
return Integer.compare(this.k, b.k);
}
}
}