EXAM 1

CS 46A Fall 2013

Exam Rules

1.  (10 points) Complete the methods in the StringUtility class.

Codecheck URL : http://go.code-check.org/codecheck/files/13091923354350886398188892317

2. (10 points) Complete the method leetSpeak method in the Leet class. Do not change the original word in any way.

Example: break -> 812e4k

Codechek URL: http://go.code-check.org/codecheck/files/13091922564938792600020041313

3. (10 points)The planet Java has some very strangly shaped buildings - one is shown below along with its dimensions. You are to complete the Building classby implementing the volume method.

The planet does not have breathable air and so the buildings need to be filled with air earth normal pressure. One of the methods of the Building class calulates the volume of the Building bases on the height, x, so the engineers can figure out how much air will be needed.

The volume of the building is the volume of the rectangle + the volume of the cube.

(3x)(2x)(x) + 2x(x2)π = 6x3 + 2x3π
(Don't spend time trying to figure this out. Just use the formula)

Use Math.PI

building

Codecheck URL: http://go.code-check.org/codecheck/files/13091922292178357749823441713

4. (10 points) Complete the class called SelectionDemo. Its main method will do the following.

Codecheck URL: http://go.code-check.org/codecheck/files/13100601023twfsu5ceaz5y3112n3kmwwl0

5. (10 points)You are given a Sphere class. Your job is to complete the SphereDemo's main method to do these things.

Use this statement to print the volume:

System.out.printf("Volume:%8.2f\n", volume);

Codecheck URL: http://go.code-check.org/codecheck/files/13091718517334995187890390625

6. (10 points) Complete the class DrawingPractice. Using the graphics package from the Udacity videos (also included in the zip of the exam) draw a rectangele at at coordinates (30, 20) with a width of 50 and a height of 40. Create the Ellipse that fits is surrounded by tis rectangle. Fill it with the color red defined in tthe Color class. Lastly, draw a line from the upper left-hand corner of the rectangle to the lower right-hand corner.

The image should look like this.

screen shot of drawing

Codecheck URL: http://go.code-check.org/codecheck/files/13091722431343873532525452140