Question: Write in Java, a program that simulates this magic trick. ------- Skeleton Java program: package Lab09; import java.util.*; /** * MagicTrick is a program that
Write in Java, a program that simulates this magic trick.


------- Skeleton Java program:
package Lab09; import java.util.*; /** * MagicTrick is a program that will guess a number that user is thinking of. * * @author atb * @version 10/23/2018 */ public class MagicTrick { public final int NUM_OF_SEQUENCES = 5; public final int NUMBERS_PER_SEQUENCE = 16; private ArrayList[] sequences; public MagicTrick() { // TODO Project 5 // create this.sequences object // using a for loop create ArrayList object for each slot and fill it with appropriate values } public void displaySequences() { // TODO Project 5 } public void guessNumber(String[] answer) { // TODO Project 5 } public static void main(String[] args) { MagicTrick magic = new MagicTrick(); System.out.println("Think of a number between 1 and 31 "); magic.displaySequences(); System.out.println(" List all the sequences that your number is in (ie. 1 3)"); Scanner scan = new Scanner(System.in); magic.guessNumber(scan.nextLine().split(" ")); } }
---------

V. MagicTrick The following magic trick is almost magic. With some numerical sequences you guess the number a person thinks of: Ask a person to think of a number from 1 to 31, e.g. 19 Now show five numerical sequences to the person (see the sequences in sample runs below) The person shall tell you, in which sequence the number appears. 19 in our example appears in sequence 1, 2, and 5 Add the first numbers of the sequences the person named -the sum is the number the person is thinking of: 1. 2. 3. 4. a. The numerical sequences that the person named begin with numbers 1, 2, and 16 b. 1+2+16 is 19 Write a program that implements this magic trick. The constructor should generate the sequences and store them in an array of ArrayList Integer>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
