Download A04.txt and copy it into a new Eclipse project named {NetID}A04.

Rename (refector) {NETID}A03.java to {NETID}A04.java
Modify the return type of magicEightBallIf and magicEightBallCase so they return a String instead of printing the result.
Create a static method named createStringArray with an integer argument named "count". This method should create an array that is "count" long. It should fill the array with the results of "count" calls to magicEightBallCase. It should fill from index 0 to index "count-1". It should return the created array.

public static void main(String[] args) {
// TODO Auto-generated method stub

magicEightBallIf();

magicEightBallCase();

magicEightBallLoop();

// Create an array named answers and stored the results
// of magicEightBallAnswers in the newly created array
String[] answers = magicEightBallAnswsers(100);

// We are looping over the array from 0 to array length
// printing the answer provided by the magicEightBallIf statements
// that were called in the magicEightBallAnswers method
for( int i = 0; i < answers.length; i++ ) {
System.out.println( i + ": " + answers[i] );
}

}

public static void magicEightBallIf() {

int r = getRandom();
if( r == 1 ) {
System.out.println("It is certain");
} else if( r == 2 ) {
System.out.println("It is decidedly so");
} else if( r == 3 ) {
System.out.println("Without a doubt");
} else if( r == 4 ) {
System.out.println("Yes definitely");
} else if( r == 5 ) {
System.out.println("You may rely on it");
} else if( r == 6 ) {
System.out.println("As I see it, yes");
} else if( r == 7 ) {
System.out.println("Most likely");
} else if( r == 8 ) {
System.out.println("Outlook good");
} else if( r == 9 ) {
System.out.println("Yes");
} else if( r == 10 ) {
System.out.println("Signs point to yes");
} else if( r == 11 ) {
System.out.println("Reply hazy try again");
} else if( r == 12 ) {
System.out.println("Ask again later");
} else if( r == 13 ) {
System.out.println("Better not tell you now");
} else if( r == 14 ) {
System.out.println("Cannot predict now");
} else if( r == 15 ) {
System.out.println("Concentrate and ask again");
} else if( r == 16 ) {
System.out.println("Don't count on it");
} else if( r == 17 ) {
System.out.println("My reply is no");
} else if( r == 18 ) {
System.out.println("My sources say no");
} else if( r == 19 ) {
System.out.println("Outlook not so good");
} else if( r == 20 ) {
System.out.println("Very doubtful");
}

}

public static void magicEightBallCase() {

int r = getRandom();

switch( r ) {
case 1:
System.out.println("It is certain");
break;
case 2:
System.out.println("It is decidedly so");
break;
case 3:
System.out.println("Without a doubt");
break;
case 4:
System.out.println("Yes definitely");
break;
case 5:
System.out.println("You may rely on it");
break;
case 6:
System.out.println("As I see it, yes");
break;
case 7:
System.out.println("Most likely");
break;
case 8:
System.out.println("Outlook good");
break;
case 9:
System.out.println("Yes");
break;
case 10:
System.out.println("Signs point to yes");
break;
case 11:
System.out.println("Reply hazy try again");
break;
case 12:
System.out.println("Ask again later");
break;
case 13:
System.out.println("Better not tell you now");
break;
case 14:
System.out.println("Cannot predict now");
break;
case 15:
System.out.println("Concentrate and ask again");
break;
case 16:
System.out.println("Don't count on it");
break;
case 17:
System.out.println("My reply is no");
break;
case 18:
System.out.println("My sources say no");
break;
case 19:
System.out.println("Outlook not so good");

break;
case 20:
System.out.println("Very doubtful");
break;

}

}

public static void magicEightBallLoop() {
for( int i = 0; i < 100; i++ ) {
magicEightBallIf();
}
}



//
/*
*
*/
/**
* Added i to j and return the sum
*
* @param i
* @param j
* @return
*/
public static int sum( int i, int j ) {
return i + j;
}

/**
* Added i to j and return the sum
*
* @param i
* @param j
* @return
*/
public static double sum( double i, double j ) {
return i + j;
}

/**
* Append i to j separated by a space
* @param i
* @param j
* @return
*/
public static String append( int i, int j ) {
return i + " " + j;
}

/**
* Append tail to base
* @param base
* @param tail
* @return
*/
public static String append( String base, String tail ) {
return base + tail;
}

/**
* Example of how to break your code this matches the above method
* @param base
* @param tail
* @return
*/
/*
public static int append( String base, String tail ) {
return 0;
}
*/


/**
* Execute the magic eight ball code i times storing the
* results in an array.
*
* Return said array to the caller
* @param i
* @return
*/
public static String[] magicEightBallAnswsers( int i ) {

String[] answers = new String[i];

for( int j = 0; j < answers.length; j++ ) {

answers[j] = magicEightBallIfString();


}

return answers;

}



public static String magicEightBallIfString() {

int r = getRandom();
if( r == 1 ) {
return "It is certain";
} else if( r == 2 ) {
return "It is decidedly so";
} else if( r == 3 ) {
return "Without a doubt";
} else if( r == 4 ) {
return "Yes definitely";
} else if( r == 5 ) {
return "You may rely on it";
} else if( r == 6 ) {
return "As I see it, yes";
} else if( r == 7 ) {
return "Most likely";
} else if( r == 8 ) {
return "Outlook good";
} else if( r == 9 ) {
return "Yes";
} else if( r == 10 ) {
return "Signs point to yes";
} else if( r == 11 ) {
return "Reply hazy try again";
} else if( r == 12 ) {
return "Ask again later";
} else if( r == 13 ) {
return "Better not tell you now";
} else if( r == 14 ) {
return "Cannot predict now";
} else if( r == 15 ) {
return "Concentrate and ask again";
} else if( r == 16 ) {
return "Don't count on it";
} else if( r == 17 ) {
return "My reply is no";
} else if( r == 18 ) {
return "My sources say no";
} else if( r == 19 ) {
return "Outlook not so good";
} else if( r == 20 ) {
return "Very doubtful";
}


return "ERROR";

}




/**
* Instructors random number generator do not touch!
*/
private static Random random = new Random(4);

public static int getRandom() {
return random.nextInt(19) + 1;
}

}

/*

System.out.println("It is certain");
System.out.println("It is decidedly so");
System.out.println("Without a doubt");
System.out.println("Yes definitely");
System.out.println("You may rely on it");
System.out.println("As I see it, yes");
System.out.println("Most likely");
System.out.println("Outlook good");
System.out.println("Yes");
System.out.println("Signs point to yes");
System.out.println("Reply hazy try again");
System.out.println("Ask again later");
System.out.println("Better not tell you now");
System.out.println("Cannot predict now");
System.out.println("Concentrate and ask again");
System.out.println("Don't count on it");
System.out.println("My reply is no");
System.out.println("My sources say no");
System.out.println("Outlook not so good");
System.out.println("Very doubtful");

*/

To complete the given task, follow the steps outlined below:

1. Download A04.txt file and save it in a suitable location on your computer.

2. Open Eclipse IDE and create a new project named {NetID}A04. Replace "{NetID}" with your actual NetID.

3. Copy the content of the downloaded A04.txt file and paste it into the {NetID}A04 project's main class file.

4. Rename the existing file {NETID}A03.java to {NETID}A04.java. Replace "{NETID}" with your actual NetID.

5. Modify the return types of the methods `magicEightBallIf` and `magicEightBallCase` to return `String` instead of printing the result. Update the method signatures as follows:

```java
public static String magicEightBallIf() {
// Existing code
}

public static String magicEightBallCase() {
// Existing code
}
```

6. Create a new static method named `createStringArray` that takes an integer argument named "count" and returns a `String` array. This method will create an array of length "count" and fill it with the results of "count" calls to the `magicEightBallCase` method. The method should fill the array from index 0 to "count-1". Use the following code:

```java
public static String[] createStringArray(int count) {
String[] answers = new String[count];
for (int i = 0; i < count; i++) {
answers[i] = magicEightBallCase();
}
return answers;
}
```

7. In the `main` method, replace the existing code with the following:

```java
public static void main(String[] args) {
magicEightBallIf();
magicEightBallCase();
magicEightBallLoop();

String[] answers = createStringArray(100);

for (int i = 0; i < answers.length; i++) {
System.out.println(i + ": " + answers[i]);
}
}
```

8. Now, you can run the program and check the output.

Please make sure you have the necessary Eclipse project set up and the A04.txt file downloaded before starting the steps mentioned above.