Feel free to participate in a different group than last time. This is totally up to you, but try to find a group that makes it easy for you to participate.Be careful how you use the web. You are required to develop solutions as a group by thinking not by finding solutions that have been thought out by others. You must be able to explain anything that you have done.
Note for Fall 2013: Because we missed Thursday of last week, just pick ONE of the following problems for studio (Problem 1 or Problem 2), and work on the other one at your convenience.Studio today will be the first 45 minutes. In the remaining time, you will demo Lab 1, have recitation on Module 2, and take Quiz 1.
DNA is comprised of two long polymers (often called strands) of nucleotides. Each nucleotide is commonly one of four possible bases denoted by a single character: A, T, C, or G.
An organism's DNA, once determined, is often represented as a string whose characters that represent a portion of one strand of the DNA.
One property of interest to biologist is the GC content of DNA: what fraction of an organism's DNA are the bases G or C?
In this studio, your team should do the following:
Be sure to check the box that generates public static void main. Otherwise you will have to type that by hand.
If you don't remember how to do this, look at code from a previous studio or lab.
You should ensure that your code works properly for edge cases. For example, what happens if the user specifies 0 as the desired length?Also, because you are using the random-number generator, your output should look different among different runs.
Some notes:
- Case matters. A G and a g are two different characters. Be sure you are looking for the proper case.
- If you have a String s, then the caracter at position i can be gotten by:
char r = s.charAt(i);- Note that the first chracter in s occurs at location 0. If s has n characters, then its last character occurs at location n-1.
- To compare r to a character constant, surround that character constant with single quotes, as in:
if (r == 'G') { System.out.println("I saw a G."); }
Computer scientists often use simulation as a means of modeling, understanding, and predicting real-world phenomena.
Your group is auditioning for Survivor by proving your group's ability to compute Pi using only the materials at hand, as follows:
While the thrower never misses the unit square, the darts land sometimes within the inscribed circle, sometimes not.
This may be the first new Class you have developed, but eclipse makes it easy:
- Right-click on the package name in which you want to define the new class. In this case, use studio2.
- Click New...
- Choose Class
- Pick the name Pi for this class, since the code you will paste is for class Pi. Java style dictates that its classes should begin with a capital letter!
- When the editor opens for your new class, copy and paste the code from Pi.java into the class.
You will need to simulate a random dart thrower. The function math.random() will help, as it returns a nonnegative double less than 1.0. You may also find the Math.sqrt() function to be helpful.
If you have time, pick one or both of the following:
When you done with this studio, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches
- If you request propagation, it does not happen immediately, but should be posted in the next day or so