Question
Write a program to simulation mutation by starting with an input sequence of letters of arbitrary length up to a maximum of 80 and then for 25 generations randomly choose one letter for mutation. There should be an equal probability for a letter to be chosen, and an equal probability for which of the four letters it could become.
Your program should print the original sequence, and then the 25 resulting sequences. If it should happen that two adjacent sequences are identical, you should print an asterisk at the end of the second of the two sequences.
At the end of the output, you should print an asterisk below the column of any letter that did not change during the course of the simulation.
An example run of the program should appear like this:
$ java Student
Enter a DNA sequence up to 80 bp:
ATTCGGCTA
ATTCGGCTA
ATCCGGCTA
ATCCGTCTA
ATCCGTCTA *
...ATCCGTCTT
AACCGTCTT
AATCGTCTT
* ** **
You should not print the ellipses, of course, but rather the entire 26 lines of output.
Use an array of characters for this program. Do not use ArrayLists or strings. Write methods as necessary, and follow all the rules of the style guide.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
import java.util.Scanner;public class Mutation {
public static void mutationSimulation(char[] sequence)
{
int size = sequence.length;
boolean[] change = new boolean[size];
for(int i = 0 ;i < 0; i++)
change[i] = false;
char[] letters = {'A', 'C', 'G', 'T'};
System.out.println(sequence);
for(int i = 0; i < 25; i++)
{
int position = (int)(Math.random()*size);...