Biggest prime numbers

Report a typo

Find the three biggest prime numbers in the given range. In some cases, you may have fewer prime numbers.

  • If there are only two prime numbers, print the following script, replacing firstPrime and secondPrime by their value: There aren't enough elements in a queue. You added two: firstPrime and secondPrime.
  • If there is only one element, print There aren't enough elements in a queue. You added only 61.
  • If there isn't any prime number, print The queue is empty.

Sample Input 1:

2 10

Sample Output 1:

7
5
3
Write a program in Java 17
import java.util.Scanner;
import java.util.*;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Queue<Integer> queue = new PriorityQueue<>(new IntegerComparator());

int start = scanner.nextInt();
int end = scanner.nextInt();

for (int i = start; i <= end; i++) {
// add elements to a queue here
}
}
}

class IntegerComparator implements Comparator<Integer> {
@Override
public int compare(Integer i1, Integer i2) {
// write your code here
}
}
___

Create a free account to access the full topic