Question: From Wikipedia (https://en.wikipedia.org/wiki/Decimation_(punishment)): In the military of ancient Rome, decimation was a form of military discipline in which every tenth man in a group

From Wikipedia (https://en.wikipedia.org/wiki/Decimation_(punishment)): In the military of ancient Rome, decimation was a

From Wikipedia (https://en.wikipedia.org/wiki/Decimation_(punishment)): In the military of ancient Rome, decimation was a form of military discipline in which every tenth man in a group was executed by members of his cohort. A cohort (roughly 480 soldiers) selected for punishment by decimation was divided into groups of ten. Each group drew lots, and the soldier on whom the lot of the shortest straw fell was executed by his nine comrades, often by stoning, clubbing, or stabbing. Let's write a program that will simulate the decimation of a population. Decimation does not have to be 1 in 10 ( 10 % of the population). It could be 1 in 8 (12.5% of the population) or 1 in 12 (8.3% of the population). In our simulation, we will let the user decide the amount to reduce the population by. You will need to write 2 methods. 1. displayArray(): this method takes as parameters the populationarray and reduction ratio X and then will print out the contents of the array in rows of the appropriate length (if the reduction 10%, then it is reduced by 1 in 10, so it should be displayed in rows of 10 elements. If the reduction is 14%, then it is 1 in 7, so it should be displayed in rows of 7 elements. Hint: Use integer division to do this, you cannot have partial elements). Its signature should be: public static void printArray (int[] orgArray, int reduce By) 2. myDecimator(): This method will "kill" 1 element in each group by setting its value to 0. The parameters passed are the array and the reduction integer (the X in the 1 in X reduction ratio). The method should remove a random element from each reduction block by replacing the contents of the randomly chosen element with O. (Arrays are always passed by reference, so there is nothing to return, you do not need a second array). It's signature should be: public static void myDecimator(int[] orgArray, int reduceBy). The process the program should implement is: 1. Prompt the user for the size of the population to decimate, and what percentage to reduce the population by. Input this as a double and use it to calculate your X. 2. Create an array of the entered population size and populate it with random positive integer numbers 1-99. 3. Display the message "The array before a 1 in X reduction", where X is the denominator in the reduction ratio. 4. Call your display Array() method to display the population array formatted into rows of length x. Each of these rows is a block that will have an element "killed" by our decimation method. 5. Call MyDecimator(): 6. Display the message "The Array after a 1 in X reduction"

Step by Step Solution

3.40 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!