Question: public class Josephus { public static void main ( String [ ] args ) { boolean [ ] people = { true , true, true,
public class Josephus public static void mainString args boolean people true true, true, true, true, true, true, true, true, true; int loopCounter ; int numLiving people.length; int killCounter ; int skipCount ; while numLiving if peopleloopCounter killCounter; if killCounter skipCount peopleloopCounter false; numLiving; killCounter ; loopCounter; if loopCounter people.length loopCounter ; for int i ; i people.length; i if peoplei System.out.printlnThe safe spot is: i; break; You will write an application that will simulate the Josephus scenario. The user will be allowedto enter values for the starting index for the counting, the number of people to skip before killingand the number of people in the circle You will use a boolean array to represent the circle of people True elements of the array represent a living person, false elements are dead people When counting upward toward the target number to kill a person, you will not count falseelements. You will only count living people When the simulation ends, the program should output the safe spot to stand. That is thelast index that is true in the array after the rest were set to false How you implement this problem is up to you but I require that you use loops for arraytraversalCan you check if these requirements are matching the code I did
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
