I am quite a beginner at programming.. was given an assignment and don't understand how to complete the rest of it. I have tried for hours and hours and can't figure it out. I would greatly appreciate the assistance as to I have no clue what I am doing.
Write a program in Java that stores the following sequence that is comprised of only 'A','C','G', & 'T' characters: [ATGACATCTCTCCATACG]. The program should store the sequence both as a String and as a char[].
The program should accept two inputs from the user: -A single character with the only allowable values are either 'A','C','G', or 'T', and -An integer value that is greater than 0 and smaller than the length of the sequence.
Your program should then produce the following as output: -It prints a total count of the occurrences of the single character provided as input.
-It identifies the locations where the character entered by the user appears in the sequence at a location that is greater than or equal to the integer value provided as input by the user
-It generates a new list with the character entered by the user replaced by an asterisk ['*'] according to the previous requirement.
-Your program should provide two sets of methods to implement this functionality: one set dealing with the sequence as a char[] and the other set of methods dealing with the sentence as an instance of String.
-Your program should do the necessary checking on the values provided for the character and integer inputs to prevent the values provided by the user from getting your program to malfunction.
-You should provide as output test cases of your program for a user input corresponding to each of the four letters, naely: 'A','C','G', & 'T', and for two integer values: 0 and 4 - for a total of eight test cases.
__________________________________________________ __________________________________________________ _______
This is what I have so far, let me know what I need to do! THANKS!!
package Java; import static Java.CountEachLetter.countLetters; import java.util.regex.*; import java.util.*; import java.util.Scanner; public class Sequence { public static void main(String[] args) { Scanner input = new Scanner(System.in); // Prompt the user to enter a string System.out.print("Enter a string: "); String s = input.nextLine(); // Counts each letter to Lower Case int[] counts = countLetters(s.toLowerCase()); // Display results for (int i = 0; i < counts.length; i++) { if (counts[i] != 0) System.out.println((char)('A' + i) + " appears " + counts[i] + ((counts[i] == 1) ? " time" : " times")); } // String result = input.replace("*", "asterisk"); //matching String seq = input.nextLine(); Pattern p = Pattern.compile(""); //"C*A*" //"C*A+" Matcher m = p.matcher(seq); // boolean res = m.matches(); // System.out.println("matching CCC " + res); System.out.println(m.replaceAll("*")); //replace all ACC with _? seq = "CGTATCCCACAGCACCAACATTTTTTCCAACAACCCCA"… p = Pattern.compile("AC+A"); m = p.matcher(seq); // System.out.println("replacing all AC+C with _"); //System.out.println(m.replaceAll("*")); System.out.println(); } }