Programming



Item Name

A codon is a triplet of nucleotides that specifies a single amino acids (a prote

A codon is a triplet of nucleotides that specifies a single amino acids (a protein is a sequence of amino acids). Write a program that outputs codons given a DNA(or RNA) sequence. For example, if the input is GATTCGATC, the program outputs GAT, TCG, and ATC. Output one codon per line. If the length of an input string is not a multiple of 3, then ignore any leftover nucleotides. For example, if...

A complex number is a number of the form where

A complex number is a number of the form where a and b are real numbers and i is √-1. The numbers a and b are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formula: a + bi + c + di = (a + c) + (b + d)i a + bi – (c + di) = (a – c) + (b – d)i (a +...

A convex four-vertex polygon is divided into four triangles, as

A convex four-vertex polygon is divided into four triangles, as shown in Figure 11.10. Write a program that prompts the user to enter the coordinates of four vertices and displays the areas of the four triangles in increasing order. Here is a sample run: Enter x1, y1, x2, y2, x3, y3, x4, y4: -2.5 2 4 4 3 -2 -2 -3.5 The areas are 6.17 7.96 8.08 10.42

A criticism of the break statement and the continue statement

A criticism of the break statement and the continue statement is that each is unstructured. Actually, these statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. Use the technique you develop here to remove the break statement...

A dictionary is stored as a property list at this

A dictionary is stored as a property list at this URL: http://bit.ly/aycNwd.Write a program to read the contents of this dictionary and display its contents. What data does the dictionary contain?

A formula to compute the Nth Fibonacci number was given

A formula to compute the Nth Fibonacci number was given in Exercise 10 in Chapter 3. The formula is useful in finding a number in the sequence, but a more efficient way to output a series of numbers in the sequence is to use the recurrence relation FN = FN-1 + FN-2, with the first two numbers in the sequence F1 and F2 both defined as 1. Using this recurrence relation, we can compute the first 10...

A golf club wants to set up a membership program

A golf club wants to set up a membership program that can send mail, e-mails, and voting ballots to its members. The membership consists of junior, regular, and senior golfing members, plus a social membership, which excludes golf. The problem is that junior and social members are not allowed to vote on club issues. Also, social members should not receive mailings about golf tournaments because...

A good way to understand copy-control members and constructors i

A good way to understand copy-control members and constructors is to define a simple class with these members in which each member prints its name: struct X { X() {std::cout

A graph consists of vertices and edges that connect vertices.

A graph consists of vertices and edges that connect vertices. Write a program that reads a graph from a file and displays it on a panel. The first line in the file contains a number that indicates the number of vertices (n). The vertices are labeled as 0, 1,…., n-1. Each subsequent line, with the format u x y v1, v2, ..., describes that the vertex u is located at position (x, y) with edges (u,...

A graph consists of vertices and edges that connect vertices.

A graph consists of vertices and edges that connect vertices. Write a program that reads a graph from a file and displays it on a panel. The first line in the file contains a number that indicates the number of vertices (n). The vertices are labeled as 0, 1, ..., n-1. Each subsequent line, with the format u x y v1, v2, ..., describes that the vertex u is located at position (x, y) with the edges...