Homework 7 (DNA) FAQ

Q: Where do I start?

A: Try to break the problem into pieces. First try to read a DNA sequence (a name and a string of A, C, G, and T nucleotides) from the file. Then try to count the As, Cs, Gs,and Ts. Questions 6 and 7 from Section Handout #7 should give you some hints on how to do this.

Q: How do I examine the letters of the line to see whether they are A, C, G or T?

A: Look at section 4.4 in the text book and look over section 7 problems about text processing. The String class's charAt method is useful.

Q: How do I place the A, C, G or T into the right element of the array, when counting them?

A: Look at problem 7 on Section 7 handout. It's okay to use if/else statements to express the mapping between the characters and the array indexes, as long as you avoid redundancy as much as possible.

Q: I have a lot of repetitive code. How do I make it less redundant?

A: You must work especially hard on this assignment to eliminate redundancy. Use techniques we've practiced in the past, such as factoring common code out of an if/else statement, or creating a helping method to hold common code.