import java.util.Scanner; public class Josephus { public static void main(String[] args) { System.out.println("Enter the total number of people in a circle:"); Scanner scanner = new Scanner(System.in); int numPeople = scanner.nextInt(); System.out.println("Every nth person will be killed. What do you wish n to be?"); int n = scanner.nextInt(); Queue queue = new QueueArray(); //initialize queue for (int i = 1; i <= numPeople; i++) { queue.enqueue(i); } System.out.println("Here are the people killed, in the order they died:"); while ( ! queue.isEmpty()) { for (int i = 0; i < n-1; i++) { queue.enqueue(queue.dequeue()); } //person "killed" (i.e., dequeued, but not re-enqueued) is... System.out.print(queue.dequeue() + " "); } } }